As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
How do I cascade delete entities from related collections?
M
Michael
started a topic
over 9 years ago
I have 2 collections: projects and tasks.
Projects have references to tasks. I want to delete all referenced tasks when I delete a project.
1 person has this question
1 Comment
M
Michael
said
over 9 years ago
The best way to do this is through business logic. The logic should be something like the following:
Using the collectionAccess module, find the records from the project collection that are going to be deleted by obtaining the query for deletion and executing it.
Using the async module (for speed and parallel processing), iterate through each project record to be deleted, and delete the task records associated with it.
Use a pre-delete Collection Hook on the Project collection and use code similar to the following.
function onPreDelete(request, response, modules){
var projectCollection = modules.collectionAccess.collection("project");
var taskCollection = modules.collectionAccess.collection("task");
Michael
Projects have references to tasks. I want to delete all referenced tasks when I delete a project.
1 person has this question