Cascade delate when using backlink relationship #2553
-
Hello. I have a backlink relationship through two objects inside my app
When I delete a JobwalkItem I assume that it’s JobSummary items also should delete from database. But this does not happen and I need to manually delete all related JobSummary items and then delete JobwalkItem. So the question is following. Is that an expected behavior and the cascade deletion is applicable only for embedded objects? p.s I guess that cascade deletion is not unequivocally when we have backlinks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
regarding cascading deletes there is no difference between forward links and backward links. The reason behind this is that any The idea of having an object belonging to exactly just one other object and if it (or rather: the link to it) gets deleted there the object can be removed from the database is exactly what you would express by Does that answer your questions? Feel free to ask for clarification if you need any. 👍 |
Beta Was this translation helpful? Give feedback.
Hi @vardansargsyan92,
regarding cascading deletes there is no difference between forward links and backward links.
They don't automatically do cascading deletes unless you use
EmbeddedObject
as you already expected.The reason behind this is that any
JobSummaryItem
in theIQueryable<JobSummaryItem> JobSummaryItems
in yourJobwalkItem
could also be linked in any otherRealmObject
. We therefore cannot delete them safely.Even if they weren't used anywhere else they are designed to not be deleted since they could be used somewhere else in the future.
The idea of having an object belonging to exactly just one other object and if it (or rather: the link to it) gets deleted there the object can…