-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Local
-
None
-
?
-
10
-
591
-
Kotlin Beta sprint 36, Kotlin Beta sprint 37, Kotlin Beta sprint 38, Kotlin Beta sprint 39
Similar to Realm Java, we should add support for mapping inverse relationships. The Java annotation of @LinkingObjects seem fine for this.
class Dog : RealmObject { var name: String = "Fido" @LinkingObjects("dog") val parents: RealmResult<Person> = RealmResults.empty() } class Person : RealmObject { var name: String = "Jane" var dog: Dog? = null }
In Java, the LinkingObjects implementation was highly annoying in Kotlin as it wasn't possible for end users to construct RealmResults themselves which meant that they were forced to do var parents: RealmResults<Person>? = null
We should definitely lift that restriction in the Kotlin SDK. Suggestion would be provide a RealmResults.empty() factory method that basically emulate the empty Results from Core, i.e. it always contains 0 elements. Semantics around queries, adding changelisteners etc. needs to be defined.