I am creating APIs where I don’t want objects to be deletable from a table whenever there exist relationships towards this object. What is the most efficient way of checking for this before deletion? Just do transactional Find operations for each of the tables I want to check? Or is there a simpler way?
Hello @Egil_Helland
- You can implement this using beforeDelete event handler which will check relations presence and throw an error if they are present.
- You can BULK delete using whereClause:
DELETE <host>/<appId>/<apiKey>/data/bulk/Parent
whereClause: objectId='<objectId>' and child is null
- To delete a specific object:
objectId='<objectId>' and child is null
- To delete multiple objects:
child is null
Regards,
Inna
Thanks @Inna_Shkolnaya, that seems like a superb solution. Any example code on using event handler for this?
in the BeforeRemove handler, you can search any objects which have relations to the removing item and if there are any just throw an exception and it interrupt the removing process
Regards,
Vlad
1 Like