Răsfoiți Sursa

WIP: GC-1224 refactor page model/route

* add populateDataToMakePresentation
Yuki Takei 7 ani în urmă
părinte
comite
b567de5426
1 a modificat fișierele cu 10 adăugiri și 4 ștergeri
  1. 10 4
      src/server/models/page.js

+ 10 - 4
src/server/models/page.js

@@ -293,6 +293,14 @@ module.exports = function(crowi) {
       .execPopulate();
   };
 
+  pageSchema.methods.populateDataToMakePresentation = async function(revisionId) {
+    this.latestRevision = this.revision;
+    if (revisionId != null) {
+      this.revision = revisionId;
+    }
+    return this.populate('revision').execPopulate();
+  };
+
   // TODO abolish or migrate
   // https://weseek.myjetbrains.com/youtrack/issue/GC-1185
   pageSchema.statics.populatePageListToAnyObjects = function(pageIdObjectArray) {
@@ -712,14 +720,12 @@ module.exports = function(crowi) {
    * find the page that is match with `path` and its descendants
    */
   pageSchema.statics.findListWithDescendants = function(path, userData, option) {
-    var Page = this;
-
     // ignore other pages than descendants
-    path = Page.addSlashOfEnd(path);
+    path = this.addSlashOfEnd(path);
     // add option to escape the regex strings
     const combinedOption = Object.assign({isRegExpEscapedFromPath: true}, option);
 
-    return Page.findListByStartWith(path, userData, combinedOption);
+    return this.findListByStartWith(path, userData, combinedOption);
   };
 
   /**