MutableRealm

interface MutableRealm : TypedRealm

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.

Functions

cancelWrite
Link copied to clipboard
abstract fun cancelWrite()
Cancel the write.
copyToRealm
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.
delete
Link copied to clipboard
abstract fun delete(deleteable: Deleteable)
Delete objects from the underlying Realm.
findLatest
Link copied to clipboard
abstract fun <T : BaseRealmObject> findLatest(obj: T): T?
Get latest version of an object.
getNumberOfActiveVersions
Link copied to clipboard
abstract fun getNumberOfActiveVersions(): Long
Returns the current number of active versions in the Realm file.
isClosed
Link copied to clipboard
abstract fun isClosed(): Boolean
Check if this Realm has been closed or not.
query
Link copied to clipboard
abstract override fun <T : BaseRealmObject> query(clazz: KClass<T>, query: String, vararg args: Any?): RealmQuery<T>
Returns a RealmQuery matching the predicate represented by query.
schema
Link copied to clipboard
abstract fun schema(): RealmSchema
Returns an immutable schema of the realm.
schemaVersion
Link copied to clipboard
abstract fun schemaVersion(): Long
Returns the schema version of the realm.
version
Link copied to clipboard
abstract fun version(): VersionId
Returns the Realm version of this object.

Properties

configuration
Link copied to clipboard
abstract val configuration: Configuration
Configuration used to configure this Realm instance.

Extensions

query
Link copied to clipboard
inline fun <T : BaseRealmObject> MutableRealm.query(query: String = "TRUEPREDICATE", vararg args: Any?): RealmQuery<T>
Returns a RealmQuery matching the predicate represented by query.