copyFromRealm

abstract fun <T : TypedRealmObject> copyFromRealm(obj: T, depth: UInt = UInt.MAX_VALUE): T

Makes an unmanaged in-memory copy of an already persisted io.realm.kotlin.types.RealmObject. This is a deep copy that will copy all referenced objects.

Parameters

obj

managed object to copy from the Realm.

depth

limit of the deep copy. All object references after this depth will be null. RealmLists and RealmSets containing objects will be empty. Starting depth is 0.

Throws

if obj is not a valid object to copy.


abstract fun <T : TypedRealmObject> copyFromRealm(collection: Iterable<T>, depth: UInt = UInt.MAX_VALUE): List<T>

Makes an unmanaged in-memory copy of a collection of already persisted io.realm.kotlin.types.RealmObjects. This is a deep copy that will copy all referenced objects.

Parameters

collection

the list of objects to copy. The collection itself does not need to be managed by Realm, but can eg. be a normal unmanaged List or Set. The only requirement is that all objects inside the collection are managed by Realm.

depth

limit of the deep copy. All object references after this depth will be null. RealmList and RealmSet variables containing objects will be empty. Starting depth is 0.

Throws

if the collection is not valid or contains objects that are not valid to copy.


abstract fun <T : TypedRealmObject> copyFromRealm(dictionary: RealmDictionary<T?>, depth: UInt = UInt.MAX_VALUE): Map<String, T?>

Makes an unmanaged in-memory copy of a RealmDictionary of already persisted io.realm.kotlin.types.RealmObjects. This is a deep copy that will copy all referenced objects.

Parameters

dictionary

the dictionary of objects to copy. The dictionary itself does not need to be managed by Realm, but can eg. be a dictionary produced by realmDictionaryOf. The only requirement is that all objects inside the collection are managed by Realm.

depth

limit of the deep copy. All object references after this depth will be null. RealmDictionary variables containing objects will be empty. Starting depth is 0.

Throws

if the dictionary is not valid or contains objects that are not valid to copy.