Optional properties may contain a null value or be entirely omitted from an object. By default, all properties are required unless explicitly marked as optional.
So far I ignored that because the sync between mobile works. But now I started to implement a WebApp with realm-web. This works until I try to update a object that was created by a IOS-Device via the WebApp.
If I want to update just one field from the object with the update$set:
Hi @rouuuge it appears that we’re running up against the differences between what’s supported by Objects and JSON Schema. Something to try (to allow you to modify documents in Atlas) is to click on the “Advanced Mode” button on the schema page in the Realm UI and set apply_when to false.
my problem is not that i cant modify documents in Atlas. Or maybe I missunderstand you. This post I posted on february describe the problem maybe a bit more clearer:
hi @rouuuge,
The schema that you see in the Realm UI is used for a number of things – GraphQL API, Atlas document validations, and Realm Sync. I’m assuming that the part you care about is Realm Sync. My suggested workaround should stop the schema being used for Atlas document validation, and so (after the change) the schema shouldn’t prevent you from making changes to the Atlas data.
I’ve recreated the issue and have raised the question with the engineering team. I’ll let you know when I get a response.
What was the response? It looks that you could recreated my example? If setting apply_when really the only solution could you describe bit more where to insert that rule? (btw im Using realm Sync)
I am not using GraphQL, just using iOS Sync. Where would I be able to change this?
I ran into the same issue today, do you have any update from the team?
I seems that the root cause is that no matter what the field type is, using a function to update it, it must have a value.
Non existent key, key set to null or key set to undefined does not work.
For my optional string schema, I had to pass an empty string ""
I also attempted to update an existing object in the Database that was synced from iOS Client containing an non-existent value for an optional key.
In the Collection that value was Null.
await collection.updateOne(
{ _id: ... },
{ $set: { parentId: newID }},
{ session });
// the object I am updating here contains a key
// { name: null }
it failed stating the the value that was already non existent (NULL in record) needed to be Undefined. But it was Null. (again, the NULL value was set by the sync client form the SDK or Realm server)
Expected: undefined, given: null
it looks like the validation mechanism that runs when updating a value is different that the one during a sync operation in the backend
hey @Georges_Jamous did you just found a solution? I also have a iOS-Sync App and run into the issue when i am using some serverside javascript functions.
@Sumedha_Mehta1 I had contact with you in April via mail. You suggest me this workaround:
Sounds like you’re asking for nullability support in our types. This is something we’re currently working on, but in the meantime I would suggest using the empty string, or some other dummy string because the InvalidTypeError is important for Sync.