EmbeddedRealmObject

interface EmbeddedRealmObject : TypedRealmObject

Marker interface to define an embedded model.

Embedded objects have a slightly different behavior than normal objects:

  • They must have exactly 1 parent linking to them when the embedded object is added to the Realm. Embedded objects can be the parent of other embedded objects. The parent cannot be changed later, except by copying the object.

  • They cannot have fields annotated with @PrimaryKey.

  • When a parent object is deleted, all embedded objects are also deleted.

Extensions

backlinks
Link copied to clipboard
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.
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.
parent
Link copied to clipboard
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.
inline fun <T : TypedRealmObject> EmbeddedRealmObject.parent(): T
Returns a TypedRealmObject that represents the parent that hosts the embedded object.