Remove relation collection on afterDelete(Many) or beforeDelete(Many)

System Information
  • Strapi Version: 4.1.5
  • Operating System: MacOs
  • Database: MYSQL
  • Node Version: 14.19.0
  • NPM Version: 6.14.16
  • Yarn Version: n.a.

Hi everyone,

I have the following issue:

I have a Project collection type that has a relation to a Page collection type. I made a lifecycles.js for the project collection type which creates a page entry on the beforeCreate lifecycle (and sets the correct relation) and updates the page entry on the afterUpdate lifecycle. I want to delete the page entry on the afterDelete / beforeDelete (Many) lifecycle(s) when I delete a project entry, but the corresponding event does not convey the data of the project entry that is being deleted, which means I have no way of knowing which page entry relates to said project entry. This prevents me from deleting the related page entry.

Is there any way of accomplishing the above? I’ve searched for cascade when you delete an entry but could not find a suitable answer.

TLDR: I want an option to cascade relations of a collection type when I delete an entry.

Thanks in advance!