Uploaded image for project: 'Realm Kotlin'
  1. Realm Kotlin
  2. RKOTLIN-389

Add support for `@LinkingObjects`

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Local
    • None

      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.

            Assignee:
            clemente.tort@mongodb.com Clemente Tort Barbero
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: