瀏覽代碼

Delete all activities related to a checklist when it is deleted

Ghassen Rjab 7 年之前
父節點
當前提交
a579125a1f
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      models/checklists.js

+ 5 - 3
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);
+      });
     }
   });
 }