Hello community :) I implemented lots of good working functionality with firebase -> realm. Now i tried to edit a structure and I am running through the wildest error messages.
What is right for sure:
Fields where i maybe expect an issue:
What i tried
Hopefully someone can help me here because i got completely stuck with this issue and its necesarry to continue for my project. I want to know:
Error message: Value not convertible to a number
Firebase datastructure
- "begin" : "2017-05-15T15:50:00.000Z",
- "description" : "abc",
- "end" : "2017-05-15T16:15:00.000Z",
- "id" : 6,
- "language" : [ 1 ],
- "location" : "L 1.02",
- "member" : 20,
- "referent" : [ 1, 3 ],
- "register" : true,
- "title" : "Sound of Silence",
- "track" : 6,
- "type" : 3,
- "brands" : [ 1, 2, 3 ]
Realm Schema
const ReferentListSchema = {
name: 'ReferentList',
properties: {
id: {
type: 'int',
optional: true
}
}
}
const LanguageListSchema = {
name: 'LanguageList',
properties: {
id: 'int'
}
}
const EventSchema = {
name: 'Events',
primaryKey: 'id',
properties: {
id: 'int',
begin: {
type: 'date',
optional: true
},
end: {
type: 'date',
optional: true
},
title: 'string',
description: 'string',
register: 'bool',
member: {
type: 'int',
optional: true
},
language: {
type: 'list',
objectType: 'LanguageList'
},
location: 'string',
referent: {
type: 'list',
objectType: 'ReferentList'
},
type: 'int',
track: {
type: 'int',
optional: true
},
img: {
type: 'string',
optional: true
},
brands:{
type: 'string',
optional: true
}
}
}
Realm set
set(obj) {
realm.write(() => {
if(obj.referent){
obj.referent = obj.referent.map(function(id) {
return {id};
})
}
if (obj.language){
obj.language = obj.language.map(function(id) {
return {id};
})
}
realm.create('Events', obj, true);
});
}
Solved:! The issue got solved through wrong data at firebase. Some Date Objects hasent been set correct.
How i got to the solution When i tried to debugg the code i made a try/catch block around:
try{
realm.create('Events', obj, true);
}catch(error){
console.log(obj);
console.log(error);
}
Through this debug i found the right data wich was wrong. Before it just showed me all objects and afterwards the error.
I wont close this question because of the chance to help someone with the same issues.-