I'm trying to create Realm database that has a json array of objects with a nested array of objects.
When I try to add using the code below I always get the error: JS value must be of type: object.
Schemas:
import Realm from 'realm';
class Exercise extends Realm.Object {
}
Exercise.schema = {
name: 'Exercise',
primaryKey: 'id',
properties: {
id: 'int',
name: 'string',
category: 'string',
bodyPart: 'string',
levels: {type: 'list', objectType: 'Level'}
}
};
class Level extends Realm.Object {
}
Level.schema = {
name: 'Level',
properties: {
level: 'int',
equipments: 'string'
}
};
export default new Realm({schema: [Exercise, Level, Multiplier]});
and the method where I'm trying to create the database:
realm.write(() => {
let exercise = realm.create('Exercise', {
id: 209,
name: 'Dumbbell Overhead Press',
category: 'Military Press',
bodyPart: 'Shoulder'
}, true);
exercise.levels.push({
level: 3,
equipments: 'DB'
});
});
I tried every way possible, putting the array direct in the Exercise creation, etc, I had no success..
Cheers