Began making generic tree re-arranging methods, still buggy

This commit is contained in:
Stefan Zermatten
2019-07-30 16:47:21 +02:00
parent 4b7ff2146f
commit d0304da4fd
18 changed files with 176 additions and 60 deletions

View File

@@ -1,5 +1,5 @@
import getCollectionByName from '/imports/api/parenting/getCollectionByName.js';
import updateDecendents from '/imports/api/parenting/parenting.js';
import updateDescendants from '/imports/api/parenting/parenting.js';
// 1 + n database hits
export function softRemove({_id, collection}){
@@ -12,9 +12,9 @@ export function softRemove({_id, collection}){
}, $unset: {
removedWith: 1,
}});
// Remove all the decendents that have not yet been removed, and set them to be
// Remove all the descendants that have not yet been removed, and set them to be
// removed with this document
updateDecendents({
updateDescendants({
ancestorId: _id,
filter: {removed: {$ne: true}},
modifier: {$set: {
@@ -41,7 +41,7 @@ export function restore({_id, collection}){
removedAt: 1,
}});
if (numUpdated === 0) restoreError();
updateDecendents({
updateDescendants({
ancestorId: _id,
filter: {
removedWith: _id,