ADONISJS - Is it possible to activate the beforeDelete hook of a model upon record deletion through a cascade?

25 Views Asked by At

I have the following foreign key in my table. If the farm of the record is deleted, I need the record to be deleted as well. Hence the cascade on delete.

enter image description here

This record also has a key for an image stored in the cloud that needs to be deleted as well. Therefore, before deleting the record, I need to delete the cloud image.

However, the beforeDelete hook that I added to the model is not triggered when there is direct deletion by the database.

What is the best approach to take? Is there a solution to achieve what I want, or should I configure the removal using hooks exclusively instead of using cascade in the migration?

0

There are 0 best solutions below