Is there any way to access the deleted record’s id in the “After Delete” hook?
My project is “Bond”.
JS SDK on top of NestJs
Is there any way to access the deleted record’s id in the “After Delete” hook?
My project is “Bond”.
JS SDK on top of NestJs
Hey @bond
Your should be able to access the filter and condition tree used to retrieve the records to delete in the HookHandler context (As visible here)
If you are dealing with a single record deleted, you should be able to retrieve the id of the deleted record.
As stated in the documentation, hooks are pretty low level in our API. The delete
function does not expose the deleted records.
Depending on your use-case, and if you need a complete access to the set of records after they were deleted, I would suggest to use a smart action in this context, and block the “delete” operation at a role level. The agent API should be way simpler to use.
Let me know if that helps
Thanks @jeffladiray
I’ve added a “Smart action” to the “doctor_to_specialty” collection, but it is not visible on the panel.
It would also be helpful to discuss the first solution.
I only could find context.filter.conditionTree
. Its deeper properties (conditionObject.field
) are not accessible.
Am I doing anything wrong?
I’ve added a “Smart action” to the “doctor_to_specialty” collection, but it is not visible on the panel.
You should be able to set the visibility of the smart action in your collection settings, under Smart action tab. Let me know if that’s not the case.
It would also be helpful to discuss the first solution.
I only could findcontext.filter.conditionTree
. Its deeper properties (conditionObject.field
) are not accessible.
conditionTree
is a complex object on our end.
Your can find more info here, but it can either be a Branch or a Leaf, thus can contains specific set of condition(s).
Just in case you still want to use a hook and you want to easily deal with condition trees, you could (if it matches your use-case), use a before delete hook in combination with our query interface, in order to get a manageable list of ids of records you may need.