I am trying to make a server code to delete an object with its related object at once, to avoid doing it on client side, but I am not able to do it from Codeless. Can you please help me with that?
So I am trying to create a service, where I pass id of a parent object and it creates a transaction, where it removes parent object and related object. So, as an example, I have Shop table with address field which relates to Address table.
I cannot find related object in Address table by having only parent object id. How can I do that?
In your post you’re referencing the Shop table, however, the codeless logic creates a transaction with operations for the Address and the Property tables. Please clarify what table is the parent and which one is the related table.
Is the id parameter you pass the objectId of an object in the parent table?
The codeless logic is quite wrong. Rather than adding “Delete Table Object” blocks to the transaction, you need to add operations to it. Specifically for your use case, the operation is this:
I would like to delete Property and Address objects in one transaction having only Property objectId.
I was trying to follow docs to create a transaction as you said, but its not going well for me, I cannot find Set(set MyTx) from this page Transaction API - Backendless Codeless Development Guide.
Okay, I did some progress. The only thing I am missing is how to get address related object from Find operation and pass it to delete operation in transaction. Get property is not working.
Okay, finally did it, had to get parent object first, save it to a variable and then add two delete operations to a transaction. Thanks for your help, have a great day!
The first Bulk Delete uses a where clause query that identifies the parent object. It will delete all objects that match the query, but there should be only one parent based on your schema.
The second Delete operation deletes the Address object identified by the argument value.