Skip to content

Cascade Deletes or Deleting RealmList Items from RealmObject #1339

@maarek

Description

@maarek

I have a case where I'm calling a copyToRealmOrUpdate(List) and I have noticed that the RealmList that is a property on MyObject gets updated to the new list for MyObject but old objects get orphaned and not deleted. My guess is that there is no support for cascading deletes. Since they don't have primary keys, I have no identifiable way to query them and remove them after the fact.

What would be the best possible solution for this? Would MyObject's property need to also have MyObject's primary key in order to query and delete those old orphaned objects? I could try some sort of app processing to remove them before the copyToRealmOrUpdate but it seems really heavy and only grows as the number of MyObjects grows.

Get a List
For each MyObject, query for the stored Realm MyObject.
Get RealmList from stored Realm MyObject
Loop through RealmList object and removeFromRealm

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions