Package io.realm.kotlin.ext

Functions

asBsonObjectId
Link copied to clipboard
fun ObjectId.asBsonObjectId(): <ERROR CLASS>
asFlow
Link copied to clipboard
fun <T : BaseRealmObject> T.asFlow(): <ERROR CLASS><ObjectChange<T>>

Observe changes to a Realm object. The flow would emit an InitialObject once subscribed and then, on every change to the object an UpdatedObject. If the observed object is deleted from the Realm, the flow would emit a DeletedObject and then will complete, otherwise it will continue running until canceled.

asRealmObject
Link copied to clipboard
inline fun <T : BaseRealmObject> RealmAny.asRealmObject(): T

Creates an unmanaged RealmAny instance from a BaseRealmObject value.

backlinks
Link copied to clipboard
inline fun <T : TypedRealmObject> EmbeddedRealmObject.backlinks(sourceProperty: KProperty1<T, *>): EmbeddedBacklinksDelegate<T>

Returns a BacklinksDelegate that represents the inverse relationship between two an EmbeddedRealmObject and a TypedRealmObject.

inline fun <T : TypedRealmObject> RealmObject.backlinks(sourceProperty: KProperty1<T, *>): BacklinksDelegate<T>

Returns a BacklinksDelegate that represents the inverse relationship between two Realm models.

fun <T : TypedRealmObject> EmbeddedRealmObject.backlinks(sourceProperty: KProperty1<T, *>, sourceClass: KClass<T>): EmbeddedBacklinksDelegate<T>

Defines a backlink that represents a one-to-one inverse relationship between an EmbeddedRealmObject and a TypedRealmObject.

fun <T : TypedRealmObject> RealmObject.backlinks(sourceProperty: KProperty1<T, *>, sourceClass: KClass<T>): BacklinksDelegate<T>

Defines a collection of backlinks that represents the inverse relationship between two Realm models. Any direct relationship, one-to-one or one-to-many, can be reversed by backlinks.

copyFromRealm
Link copied to clipboard
inline fun <T : TypedRealmObject> T.copyFromRealm(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.

inline fun <T : TypedRealmObject> RealmResults<T>.copyFromRealm(depth: UInt = UInt.MAX_VALUE): List<T>

Makes an unmanaged in-memory copy of the elements in a RealmResults. This is a deep copy that will copy all referenced objects.

inline fun <T : RealmObject> RealmDictionary<T?>.copyFromRealm(depth: UInt = UInt.MAX_VALUE): Map<String, T?>

Makes an unmanaged in-memory copy of the elements in a managed RealmDictionary. This is a deep copy that will copy all referenced objects.

inline fun <T : TypedRealmObject> RealmList<T>.copyFromRealm(depth: UInt = UInt.MAX_VALUE): List<T>

Makes an unmanaged in-memory copy of the elements in a managed RealmList. This is a deep copy that will copy all referenced objects.

inline fun <T : RealmObject> RealmSet<T>.copyFromRealm(depth: UInt = UInt.MAX_VALUE): Set<T>

Makes an unmanaged in-memory copy of the elements in a managed RealmSet. This is a deep copy that will copy all referenced objects.

isFrozen
Link copied to clipboard
fun BaseRealmObject.isFrozen(): Boolean

Returns whether the object is frozen or not.

isManaged
Link copied to clipboard
fun BaseRealmObject.isManaged(): Boolean

Returns whether or not this object is managed by Realm.

isValid
Link copied to clipboard
fun BaseRealmObject.isValid(): Boolean

Returns true if this object is still valid to use, i.e. the Realm is open and the underlying object has not been deleted. Unmanaged objects are always valid.

parent
Link copied to clipboard
inline fun <T : TypedRealmObject> EmbeddedRealmObject.parent(): T

Returns a TypedRealmObject that represents the parent that hosts the embedded object.

fun <T : TypedRealmObject> EmbeddedRealmObject.parent(parentClass: KClass<T>): T

Gets the parent of the embedded object, embedded objects always have an unique parent, that could be a RealmObject or another EmbeddedRealmObject.

query
Link copied to clipboard
inline fun <T : TypedRealmObject> MutableRealm.query(query: String = TRUE_PREDICATE, vararg args: Any?): RealmQuery<T>
inline fun <T : TypedRealmObject> Realm.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.

fun <T : BaseRealmObject> RealmDictionary<T?>.query(filter: String = TRUE_PREDICATE, vararg arguments: Any?): RealmQuery<T>

Query the objects in a dictionary by filter and arguments. The query is launched against the output obtained from RealmDictionary.values. This means keys are not taken into consideration.

fun <T : BaseRealmObject> RealmList<T>.query(filter: String = TRUE_PREDICATE, vararg arguments: Any?): RealmQuery<T>

Query the objects in a list by filter and arguments.

fun <T : BaseRealmObject> RealmSet<T>.query(filter: String = TRUE_PREDICATE, vararg arguments: Any?): RealmQuery<T>

Query the objects in a set by filter and arguments.

realmDictionaryEntryOf
Link copied to clipboard
fun <V> realmDictionaryEntryOf(pair: Pair<String, V>): RealmDictionaryMutableEntry<V>

Instantiates an unmanagedRealmDictionaryMutableEntry from a Pair of String and V that can be added to an entry set produced by RealmDictionary.entries. It is possible to add an unmanaged entry to a dictionary entry set. This will result in the entry being copied to Realm, updating the underlying RealmDictionary.

fun <V> realmDictionaryEntryOf(entry: Map.Entry<String, V>): RealmDictionaryMutableEntry<V>

Instantiates an unmanagedRealmMapMutableEntry from another Map.Entry that can be added to an entry set produced by RealmDictionary.entries. It is possible to add an unmanaged entry to a dictionary entry set. This will result in the entry being copied to Realm, updating the underlying RealmDictionary.

fun <V> realmDictionaryEntryOf(key: String, value: V): RealmDictionaryMutableEntry<V>

Instantiates an unmanagedRealmMapMutableEntry from a key-value pair that can be added to an entry set produced by RealmDictionary.entries. It is possible to add an unmanaged entry to a dictionary entry set. This will result in the entry being copied to Realm, updating the underlying RealmDictionary.

realmDictionaryOf
Link copied to clipboard
fun <T> realmDictionaryOf(vararg elements: Pair<String, T>): RealmDictionary<T>

Instantiates an unmanagedRealmDictionary from a variable number of Pairs of String and T.

fun <T> realmDictionaryOf(elements: Collection<Pair<String, T>>): RealmDictionary<T>

Instantiates an unmanagedRealmDictionary from a Collection of Pairs of String and T.

realmListOf
Link copied to clipboard
fun <T> realmListOf(vararg elements: T): RealmList<T>

Instantiates an unmanagedRealmList.

realmSetOf
Link copied to clipboard
fun <T> realmSetOf(vararg elements: T): RealmSet<T>

Instantiates an unmanagedRealmSet.

toRealmDictionary
Link copied to clipboard
fun <T> Iterable<Pair<String, T>>.toRealmDictionary(): RealmDictionary<T>

Instantiates an unmanagedRealmDictionary containing all the elements of this iterable of Pairs of Strings and Ts.

fun <T> Map<String, T>.toRealmDictionary(): RealmDictionary<T>

Instantiates an unmanagedRealmDictionary containing all the elements of the receiver dictionary represented by a Map of String to T pairs.

fun <T> RealmDictionaryEntrySet<T>.toRealmDictionary(): RealmDictionary<T>

Instantiates an unmanagedRealmDictionary containing all the elements of the receiver RealmDictionaryEntrySet.

toRealmList
Link copied to clipboard
fun <T> Iterable<T>.toRealmList(): RealmList<T>

Instantiates an unmanagedRealmList containing all the elements of this iterable.

toRealmSet
Link copied to clipboard
fun <T> Iterable<T>.toRealmSet(): RealmSet<T>

Instantiates an unmanagedRealmSet containing all the elements of this iterable.

version
Link copied to clipboard
fun BaseRealmObject.version(): VersionId

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