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

Evaluate how to best scope delete method on RealmObject interface

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Currently we have RealmObject.delete() as an extension method. This allows for a nice shorthand when writing

      realm.writeBlocking {
        val john = copyToRealm(Person())
        john.delete()
      }
      

      Unfortunately, this is also possible outside the write transaction

      val john = Person()
      john.delete() // Will throw an exception
      

      We should evaluate if the fluency of the API trumps making it slightly less safe or if we can find a better way to control the scope of the delete method.

      We already expose a delete method on the MutableRealm, so you can do something like this:

      realm.writeBlocking {
        val john = copyToRealm(Person())
        delete(john)
      }
      

            Assignee:
            claus.rorbech@mongodb.com Claus Rørbech (Inactive)
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: