Procházet zdrojové kódy

update generate unique path

ryoji-s před 2 roky
rodič
revize
9cddb3649d
1 změnil soubory, kde provedl 2 přidání a 4 odebrání
  1. 2 4
      apps/app/src/server/routes/apiv3/pages.js

+ 2 - 4
apps/app/src/server/routes/apiv3/pages.js

@@ -240,11 +240,9 @@ module.exports = (crowi) => {
   }
 
   async function generateUniquePath(basePath, index = 1) {
-    const Page = mongoose.model('Page');
     const path = basePath + index;
-    const response = await Page.findByPath(path);
-    const isPathExists = response != null;
-    if (isPathExists) {
+    const existingPageId = await Page.exists({ path, isEmpty: false });
+    if (existingPageId != null) {
       return generateUniquePath(basePath, index + 1);
     }
     return path;