Backendless Support
 
Need Answer

Remove related data when remove parent object

If i delete parent class I expect auto deleting the related objects

it can be optional, like third parameter in method (boolean removeRelatedData)

Leave a Comment

Comments (3)

photo
1

This could potentially lead to other problems. For example, a child object may be referenced by another parent. Should it be deleted in this case? Or what if the child object has its own child object, should that (grandchild) be deleted too? What if the grandchild has another parent?

photo
1

I understand this issue

so I wrote, it can be optional, like third parameter in method (boolean removeRelatedData)

like parameter in login (boolean stayLogedIn)

photo
1

Hi Igor

You can implement it with Business Logic. There are two variants.

1) create an API Service for remove TableRecord what you need with related data

2) or create an EventHandler "AfterRemove" (I think is better solution)

if you are using Backendless 4.x you can add your code directly in your browser

please take a look at videos below, it would help you

1) for ApiService: https://www.youtube.com/watch?v=gmfk6tbb-Ns

2) for EventHandlers: https://www.youtube.com/watch?v=XTOgPTTDo3U

Regards, Vlad