diff options
author | Ghassen Rjab <rjab.ghassen@gmail.com> | 2017-08-31 06:58:32 +0100 |
---|---|---|
committer | Ghassen Rjab <rjab.ghassen@gmail.com> | 2017-08-31 06:58:32 +0100 |
commit | a579125a1faa2ecbf3b7be535ac2ee1a2d3c5bca (patch) | |
tree | e1d19c1bb71cb0bfe26f095e7f64638f9ee52f0c | |
parent | ee938c04232ab9ac42195a35d38cb7ae11b14d48 (diff) | |
download | wekan-a579125a1faa2ecbf3b7be535ac2ee1a2d3c5bca.tar.gz wekan-a579125a1faa2ecbf3b7be535ac2ee1a2d3c5bca.tar.bz2 wekan-a579125a1faa2ecbf3b7be535ac2ee1a2d3c5bca.zip |
Delete all activities related to a checklist when it is deleted
-rw-r--r-- | models/checklists.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/models/checklists.js b/models/checklists.js index 59682720..2521412f 100644 --- a/models/checklists.js +++ b/models/checklists.js @@ -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); + }); } }); } |