Uploaded image for project: 'Realm Dart SDK'
  1. Realm Dart SDK
  2. RDART-947

Allow enforcing to-one relationships using backlinks in the opposite direction

      Problem

      I want to create two objects Tag and TagCategory such that each Tag must belong to one TagCategory and the latter can have multiple tags associated to itself.
      As per the docs, we can use backlinks to define the required inverse relationship.

      Unable to find source-code formatter for language: dart. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      @RealmModel()
      class _TagCategory {
        @PrimaryKey()
        late String name;
        late String description;
      
        late List<_Tag> tags;
      }
      
      @RealmModel()
      class _Tag {
        @PrimaryKey()
        late String id;
        late String name;
        
        @Backlink(#tags)
        late Iterable<_TagCategory> category;
      }
      

      However, doing so allows Tag to be associated with multiple TagCategories and the Tag.category returns the list of all TagCategories instead of just the one category it belongs to.

      Solution

      The present solution as per my knowledge is to enforce this at user level code.

      Alternatives

      No response

      How important is this improvement for you?

      Would be a major improvement

      Feature would mainly be used with

      Local Database only

            Assignee:
            kasper.nielsen@mongodb.com Kasper Nielsen
            Reporter:
            unitosyncbot Unito Sync Bot
            AD SDK Team 2
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: