Upon copying an object across Realms, will the write be an overwrite or a sync, for its 'List<>'?

Want to clarify how a copy across realms (e.g. ‘Realm().create(_:value:update:)’) works. If the object (same primary key) exists on the target, will it sync changes or overwrite for its List<> (including nested List<>)? [assuming ‘update:’ is ‘.modify’]

Also, does the latest version of Sync and Realm (Swift, Kotlin & Node) SDKs support ‘LinkingObjects’ within the object being copied across Realms?


This is not a complete answer, but what I have seen is that the List<> are initially copied (when new non-existent); in which such copy will also create the objects within the List<> onto that new Realm (target). THOUGH, when there are nested List<> it is not consistent to complete those (object) copies … The docs say the objects included in the List<> must be complete (i.e., must be copied over) on target Realm, but I have seen them get copied via the ‘.create()’ too (not always) - as prev stated.

As far as an update, I am not aware of that answer.

@f_s the .modify parameter will perform the minimal set of changes to make the list match the new value. LinkingObjects are just the relationship in the reverse direction and will always be available as long as the forward link relationship is defined.

@Ian_Ward thank you.

Good to know on LinkingObjects.

To confirm “minimal set of changes”, shall mean added and deleted List<> objects, or will it also update existing List<> objects with modifications?

Will these updates include the same to its nested List<> too?

.modified will also propagate changes for deep/nested modifications

1 Like