From 56f1bd28293cc633ea4657baa5f007d22c7bb2af Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Tue, 13 Nov 2018 10:07:55 +0200 Subject: [PATCH] Fixes #170 and maybe some other more subtle problems regarding soft removes not cascading properly, orphaning objects --- app/lib/functions/parenting.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/lib/functions/parenting.js b/app/lib/functions/parenting.js index fe62eacb..82ecf204 100644 --- a/app/lib/functions/parenting.js +++ b/app/lib/functions/parenting.js @@ -145,17 +145,17 @@ var checkPermission = function(userId, charId){ return true; }; -var cascadeSoftRemove = function(id, removedWithId){ +var cascadeSoftRemove = function(parentId, removedWithId){ _.each(childCollections, function(treeCollection){ treeCollection.update( - {"parent.id": id}, + {"parent.id": parentId}, {$set: { removed: true, removedWith: removedWithId, }}, {multi: true} ); - treeCollection.find({"parent.id": id}).forEach(function(doc){ + treeCollection.find({"parent.id": parentId, removed: true}).forEach(function(doc){ cascadeSoftRemove(doc._id, removedWithId); }); });