Add/remove item to one-to-many relationship

hi, i have a one-to-many relationship, need to ask some pointer in ff:

  • how i can remove an item to realmlist and persist it?
  • how i can add an item to the realmlist and persist it?
  • add additional item to the existing realmlist?

Any sample code will greatly help. Thanks

@Mohit_Sharma

…this is using realm-kotlin

Hey @Eman_Nollase! Welcome to the forums.

You use RealmList something like this :

realm.write {
  val person = copyToRealm(Person())
  val children: RealmList<Child> = person.children
  val cousin: RealmList<Child> = realmListOf()

  // Insert object
  children.add(Child("Jane"))

  // Remove object
  children.remove(0) 
}

Hi @Mohit_Sharma ,

Thanks for the reply: please check my code here

  • that line is my code for updating the list and a little above that is the inserting to the list

My issue is the i am having issue on updating the list of new entry order/s to the checks.

Any idea? thanks

Can please share what issue you are getting?