Taichi Masuyama 4 ani în urmă
părinte
comite
37d785f43a
1 a modificat fișierele cu 3 adăugiri și 2 ștergeri
  1. 3 2
      packages/app/src/server/models/page.ts

+ 3 - 2
packages/app/src/server/models/page.ts

@@ -469,7 +469,7 @@ schema.statics.recountDescendantCountOfSelfAndDescendants = async function(id: O
             $sum: '$descendantCount',
           },
           sumOfDocsCount: {
-            $sum: { $cond: { if: { $ne: ['$isEmpty', true] }, then: 0, else: 1 } }, // exclude isEmpty true page from sumOfDocsCount
+            $sum: { $cond: { if: { $eq: ['$isEmpty', true] }, then: 0, else: 1 } }, // exclude isEmpty true page from sumOfDocsCount
           },
         },
       },
@@ -488,10 +488,11 @@ schema.statics.recountDescendantCountOfSelfAndDescendants = async function(id: O
 };
 
 schema.statics.findAncestorsUsingParentRecursively = async function(pageId: ObjectIdLike, shouldIncludeTarget: boolean) {
+  const self = this;
   const target = await this.findById(pageId);
 
   async function findAncestorsRecursively(target, ancestors = shouldIncludeTarget ? [target] : []) {
-    const parent = await this.findOne({ _id: target.parent });
+    const parent = await self.findOne({ _id: target.parent });
     if (parent == null) {
       return ancestors;
     }