How to Cascade Delete Related Objects when Parent Object is deleted

I have a Parent table ‘Event’ which has a column ‘address’ (relationship object to ‘Address’ table). Is it possible to cascade delete related object when the parent record is deleted? For ex :- in my case, i need to delete the Address (child) record when the Event (parent) record is deleted. I’m using the Javascript SDK.

any update on this?

Hi Arasan,

Backendless doesn’t support the cascade deletion natively, you should do in by yourself in your code.

Ok. Thanks!

What’s the best practice for deleting children record? Should I do it in client code or should I use Backendless business logic…maybe using the beforeRemove event on the parent table?

If you need one uniform way for deleting child objects when the parent is deleted, I’d do it in server-side business logic.

I do not think there is a best practice for it though. Use-cases will vary. You need to decide on an approach that works the best for you.

Regards,
Mark

Thanks Mark. Do you have a JavaScript example (beforeUpdate or afterUpdate) of how i might delete children records? I did a quick look but couldn’t one. Thanks Dan

Use the “bulk delete” functionality described at:
https://backendless.com/documentation/data/rest/data_deleting_data_objects.htm

The where clause would look like this:
ParentTableName[relationNameInTheParentTable].objectId = ‘parentObjectId’