Goal:
Trying to update a single field for a list of object ids
All Schema: all fields are optional
Object was created with iOS SDK Client.
What an object looks like:
{
"_partition": "...*",
"_modifiedByDevice": null, // schema: object
"_modifiedByUser": null, // schema: objectId
"firstName": "test",
"lastName": "test",
"parentObjectId": null
}
Function running as logged in user with r/w sync access to partitions .
My Update Code in Function:
await myCollection.updateMany(
{ _id: { $in: toModifyObjectIds } },
{ $set: { parentObjectId: parentObject._id } },
{ session } // transaction session
)
Error
update not permitted for document with _id: ObjectID(“60df0741b5269f8f19fc2a78”) : could not validate document:
_modifiedByDevice: Invalid type. Expected: undefined, given: null
_modifiedByUser: Invalid type. Expected: undefined, given: null
–
Update:
Using { $set: { parentObjectId: parentObject._id, _modifiedByDevice: BSON.undefined, _modifiedByUser: BSON.undefined } },
changes the type in the Database from null
to Undefined
.
Then subsequent updates can omit setting BSON.undefined
value.
But the original object was created using the iOS SDK Realm Sync, which does not make sense