Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public interface MutableRealm : TypedRealm {
*/
public fun <T : RealmObject> copyToRealm(instance: T, updatePolicy: UpdatePolicy = UpdatePolicy.ERROR): T

public fun <T : RealmObject> insertToRealm(instance: T, updatePolicy: UpdatePolicy = UpdatePolicy.ERROR)

public fun <T : RealmObject> insertToRealm(instances: Collection<T>, updatePolicy: UpdatePolicy = UpdatePolicy.ERROR)

/**
* Returns a [RealmQuery] matching the predicate represented by [query].
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ internal interface InternalMutableRealm : MutableRealm {
return copyToRealm(configuration.mediator, realmReference, instance, updatePolicy)
}

override fun <T : RealmObject> insertToRealm(instance: T, updatePolicy: UpdatePolicy) {
val cache: UnmanagedToManagedObjectPointerCache = mutableMapOf()

insertToRealm(realmReference, instance, updatePolicy, cache)

cache.forEach { it.value.release() }
cache.clear()
}

override fun <T : RealmObject> insertToRealm(instances: Collection<T>, updatePolicy: UpdatePolicy) {
val cache: UnmanagedToManagedObjectPointerCache = mutableMapOf()

insertToRealm(realmReference, instances, updatePolicy, cache)

cache.forEach { it.value.release() }
cache.clear()
}

override fun delete(deleteable: Deleteable) {
deleteable.asInternalDeleteable().delete()
}
Expand Down
Loading