I have two models -
class Direction : RealmObject {
var distance : Int
var polyline : String
}
class Route : RealmObject {
var id : String
var directionList : RealmList<Direction>
}
I have been using insertOrUpdate()
to update Route class with the assumption that when I call it, the existing direction objects in directionList were removed and replaced with the new list I provided. However, I recently discovered that that is not happening. Even cascade delete is not supported when I call route.deleteFromRealm()
. So now I've ended up with hundreds of objects in Direction table with no objects referring to them.
How can I remove all those objects from Direction class which have no Route objects referring to them in Realm migration?