It turns out that, from what I can tell, having Sync in Development Mode doesn’t completely work when using the Babel Plugin.
One-to-one relationships
Setting a variable as Types.Int
car: {type: 'object', objectType: Car}
status: Types.Int = 0
Setting these in the Schema on the client does not generate a matching schema on the server, so I have to do that manually in order for the device and server to stay in sync.
Maybe these are an oversight, maybe it just isn’t addressed, but figured it would be valuable to at least document this somewhere.
Furthermore, it seems that writing to the relationship doesn’t work in any of these ways:
// passing in the description and Car object as carToLink in a function and linking after creating task
realm.write(() => {
task = realm.create(Task, {description});
task.car = carToLink;
});
// passing in the description and Car object as carToLink in a function and passing in the car while creating task
realm.write(() => {
task = realm.create(Task, {description, car: carToLink});
});
// passing in the description and getting the carToLink from the primary key
realm.write(() => {
let car = realm.objectForPrimaryKey('Car', carToLink._id
task = realm.create(Task, {description, car});
});
// passing in the description and getting the carToLink from the primary key and setting it after
realm.write(() => {
let car = realm.objectForPrimaryKey('Car', carToLink._id
task = realm.create(Task, {description);
task.car = car;
});
TypeScript is complaining about task.car:
Type ‘Car’ is missing the following properties from type ‘{ type: “object”; objectType: Car; }’: type, objectTypets(2739)
One more thing I just realized:
When attempting to access embedded objects through the {type: "object", objectType: EmbeddedCar}
when typing in TypeScript, the options are type and objectType. No translation is being done to find the actual object properties. This is probably similar to the above issue with missing properties.
Typing task.embeddedCar.
should give some properties of the car like:
task.embeddedCar.manufacturer
task.embeddedCar.model
task.embeddedCar.year
instead, it’s only giving
task.embeddedCar.type
task.embeddedCar.objectType