MutableRealm

Represents the writeable state of a Realm file.

To modify data in a Realm, use instances of this class. These are provided and managed automatically through either Realm.write or Realm.writeBlocking.

All objects created and/or obtained from the mutable realm in a write-transaction are bound to the thread executing the transaction. All operations on the mutable realm or on any of the objects contained in that realm must execute on the thread executing the transaction. The only exception is objects returned from Realm.write and Realm.writeBlocking, which are frozen and remain tied to the resulting version of the write-transaction.

Properties

Link copied to clipboard

Configuration used to configure this Realm instance.

Functions

Link copied to clipboard
abstract fun cancelWrite()

Cancel the write. Any changes will not be persisted to disk.

Link copied to clipboard
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.

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.

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.

Link copied to clipboard
abstract fun <T : RealmObject> copyToRealm(instance: T, updatePolicy: UpdatePolicy = UpdatePolicy.ERROR): T

Copy new objects into the realm or update existing objects.

Link copied to clipboard
abstract fun delete(deleteable: Deleteable)

Delete objects from the underlying Realm.

abstract fun <T : TypedRealmObject> delete(schemaClass: KClass<T>)

Deletes all objects of the specified class from the Realm.

Link copied to clipboard

Deletes all objects of the specified class from the Realm.

Link copied to clipboard
abstract fun deleteAll()

Deletes all objects from this Realm.

Link copied to clipboard
abstract fun <T : BaseRealmObject> findLatest(obj: T): T?

Get latest version of an object.

Link copied to clipboard

Returns the current number of active versions in the Realm file. A large number of active versions can have a negative impact on the Realm file size on disk.

Link copied to clipboard
abstract fun isClosed(): Boolean

Check if this Realm has been closed or not. If the Realm has been closed, most methods will throw IllegalStateException if called.

Link copied to clipboard
abstract override fun <T : TypedRealmObject> query(clazz: KClass<T>, query: String, vararg args: Any?): RealmQuery<T>

Returns a RealmQuery matching the predicate represented by query.

Link copied to clipboard
inline fun <T : TypedRealmObject> MutableRealm.query(query: String = TRUE_PREDICATE, vararg args: Any?): RealmQuery<T>
inline fun <T : TypedRealmObject> TypedRealm.query(query: String = TRUE_PREDICATE, vararg args: Any?): RealmQuery<T>

Returns a RealmQuery matching the predicate represented by query.

Link copied to clipboard
abstract fun schema(): RealmSchema

Returns an immutable schema of the realm.

Link copied to clipboard
abstract fun schemaVersion(): Long

Returns the schema version of the realm.

Link copied to clipboard
abstract fun version(): VersionId

Returns the Realm version of this object. This version number is tied to the transaction the object was read from.