Synced unset Keys from device yield null
in database. And null
fails validation if you attempt to edit this object later using cloud functions.
{
someKey: {
"bsonType": "object",
"properties": {
"url": {
"bsonType": "string"
}
},
"required": [],
"title": "FileObject"
}
}
iOS client code
class FileObject: RealmObject {
.....
var url: String?
}
let file = FileObject()
file.url = nil // maybe I am editing an existing file and removing the url
someObject = file
in database (after SYNC from iOS Client)
{
...,
someKey: {
url: null
}
}
Then if I attempt to edit this object in cloud-function or if I run schema validation in Atlas, I get an error “InvalidTypeError” on url, because it suppose to not exist, but it is null which is not a string.
So JSON validation should accept null
and consider the field non existent for primitive types