Delete all activities related to a checklist when it is deleted

This commit is contained in:
Ghassen Rjab 2017-08-31 06:58:32 +01:00
parent ee938c0423
commit a579125a1f

View file

@ -185,9 +185,11 @@ if (Meteor.isServer) {
});
Checklists.before.remove((userId, doc) => {
const activity = Activities.findOne({ checklistId: doc._id });
if (activity) {
Activities.remove(activity._id);
const activities = Activities.find({ checklistId: doc._id });
if (activities) {
activities.forEach((activity) => {
Activities.remove(activity._id);
});
}
});
}