I have two Tables:
- Restaurant - field: _id, _partition, Name
- User - field: _id, _partition,Name,RestaurantId
there is a relation ship between this two table.
No following is the record in the mongo atlas db
Restaurant:
Ex. 1, ‘PUBLIC’ , ‘ABC’
2, ‘PUBLIC’, ‘PQR’
I want to store the user data as below:
Ex: 1, ‘Res=1’, ‘John’, 1(Restaurant obj)
2, '‘Res=2’, ‘Mike’, 2
So, I Open realm with below config.
const config = {
sync: {
user: user,
partitionValue: `Res=${resId}`,
}
Realm.open(config).then((UserRealm) => {
UserRealm.write(() => {
UserRealm.create(
"User",{
_id: new ObjectId(),
_partition: `Hospital=${Id}`,
patientName: patient,
RestaurantId: {
_id:'1', //Just example
_partition: 'PUBLIC',
Name:'ABC'
}
}
);
CaseRealm.syncSession.uploadAllLocalChanges().then(() => {
CaseRealm.close();
});
});
})
It adds the data into local realm but then it is throwing an error like:
Synchronisation fail: error code: 212
Can’t we write the data like this. Can some one please help what is wrong!!