usernotnull
usernotnull

Reputation: 3628

RealmObject relationships on deletion

quick question concerning Realm objects and their relationships.

Let's say, I have author1 with field Realmlist, having added book1 and book2 to that list. Creating one transaction to add author1 to realm will automatically add book1 and book2 to the database as I noticed. author1 has a reference to the books, but the books do not have a reference to their author.

My question is, what happens if I delete author1 from realm? What will happen to book1 and book2? Should I first call getBookList() and delete them or will they be automatically deleted from my database?

Upvotes: 1

Views: 173

Answers (1)

usernotnull
usernotnull

Reputation: 3628

as beeender mentioned the cascading deletes are still an issue. My solution is to link each book to the author, do a fori instead of a foreach loop and delete the books one by one before deleting the main author.

Still open to other answers though.

Upvotes: 2

Related Questions