Răsfoiți Sursa

use already-defined condition for mongoose filter

yohei0125 4 ani în urmă
părinte
comite
875b313395

+ 0 - 10
packages/app/src/server/models/page.ts

@@ -432,16 +432,6 @@ export class PageQueryBuilder {
     return this;
   }
 
-  addConditionToListByRegexp(regexp) {
-    this.query = this.query
-      .and({
-        path: {
-          $in: regexp,
-        },
-      });
-    return this;
-  }
-
   addConditionToListByPageIdsArray(pageIds) {
     this.query = this.query
       .and({

+ 2 - 2
packages/app/src/server/service/page.ts

@@ -3093,7 +3093,7 @@ class PageService {
     if (hasSlash(parentPathOrId)) {
       const path = parentPathOrId;
       const regexp = generateChildrenRegExp(path);
-      queryBuilder.addConditionToListByRegexp(regexp);
+      queryBuilder.addConditionToListByPathsArray(regexp);
     }
     else {
       const parentId = parentPathOrId;
@@ -3118,7 +3118,7 @@ class PageService {
     const queryBuilder = new PageQueryBuilder(Page.find(), true);
     await queryBuilder.addViewerCondition(user, userGroups);
     const _pages = await queryBuilder
-      .addConditionToListByRegexp(regexp)
+      .addConditionToListByPathsArray(regexp)
       .addConditionAsMigrated()
       .addConditionToMinimizeDataForRendering()
       .addConditionToSortPagesByAscPath()