kotlin-extensions / io.realm.kotlin / io.realm.Realm

Extensions for io.realm.Realm

createEmbeddedObject

Instantiates and adds a new embedded object to the Realm.

fun <T : RealmModel> Realm.createEmbeddedObject(parentObject: RealmModel, parentProperty: String): T

createObject

Instantiates and adds a new object to the Realm.

fun <T : RealmModel> Realm.createObject(): T

Instantiates and adds a new object to the Realm with the primary key value already set.

fun <T : RealmModel> Realm.createObject(primaryKeyValue: Any?): T

delete

Deletes all objects of the specified class from the Realm.

fun <T : RealmModel> Realm.delete(): Unit

executeTransactionAwait

Suspend version of Realm.executeTransaction to use within coroutines.

suspend fun Realm.executeTransactionAwait(context: CoroutineContext = Realm.WRITE_EXECUTOR.asCoroutineDispatcher(), transaction: (realm: Realm) -> Unit): Unit

syncSession

Returns the SyncSession associated with this Realm.

val Realm.syncSession: SyncSession

toflow

Creates a Flow for a Realm. It should emit the initial state of the Realm when subscribed to and on each subsequent update of the Realm.

fun Realm.toflow(): Flow<Realm>

where

Returns a typed RealmQuery, which can be used to query for specific objects of this type

fun <T : RealmModel> Realm.where(): RealmQuery<T>