These are the schema defined:
export class Farm extends Realm.Object {
static schema = {
name: 'farms',
properties: {
_id: {type: 'objectId', default: () => new BSON.ObjectId()},
__v: 'int?',
activities: 'string[]',
address: 'farm_address',
fertilizers: 'farm_fertilizers[]',
foliars: 'farm_foliars[]',
fungicides: 'farm_fungicides[]',
name: 'farm_name',
pesticides: 'farm_pesticides[]',
plants: 'farm_plants[]',
tags: 'string[]',
visibleTags: 'string[]',
},
primaryKey: '_id',
};
}
export class Farm_Foliars extends Realm.Object {
static schema = {
name: 'farm_foliars',
embedded: true,
properties: {
_id: 'objectId?',
name: 'farm_foliars_name',
tags: 'string[]',
quantity: 'farm_foliars_quantity',
},
};
}
This is the code to append new data to the existing selected “farm” under the “foliars” property:
realm.write(() => {
farm.foliars = farm.foliars.concat({
_id: new BSON.ObjectId(),
name: {eng: 'Test foliar 6', chs: '', cht: ''},
tags: ['all'],
quantity: {mass: 0, volume: 11.3},
});
console.log('Successfully added');
});
This is the error message:
I had spent a few days solving this error and I am not able to find any documentation or article to solve this error. I had tried using realm.create() method which also resulted in the same error.