Realm Function schema problem while updating records

Update:

Using BSON.undefined in Cloud Function update succeeded but generated with a sync error in device:

"Detailed Error: expected element at path { table: \"XXX\", fullPath: \"_modifiedByDevice\" } to be an embedded document, was primitive.Undefined instead"