|
|
@@ -280,7 +280,7 @@ module.exports = function(crowi) {
|
|
|
pageSchema.statics.findUpdatedList = function(offset, limit, cb) {
|
|
|
this
|
|
|
.find({})
|
|
|
- .sort('updatedAt', -1)
|
|
|
+ .sort({updatedAt: -1})
|
|
|
.skip(offset)
|
|
|
.limit(limit)
|
|
|
.exec(function(err, data) {
|
|
|
@@ -348,25 +348,46 @@ module.exports = function(crowi) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- pageSchema.statics.findListByPageIds = function(ids, options) {
|
|
|
+ pageSchema.statics.findListByPageIds = function(ids, option) {
|
|
|
};
|
|
|
|
|
|
- pageSchema.statics.findListByStartWith = function(path, userData, options) {
|
|
|
+ pageSchema.statics.findListByCreator = function(user, option) {
|
|
|
var Page = this;
|
|
|
+ var limit = option.limit || 50;
|
|
|
+ var offset = option.skip || 0;
|
|
|
|
|
|
- if (!options) {
|
|
|
- options = {sort: 'updatedAt', desc: -1, offset: 0, limit: 50};
|
|
|
+ return new Promise(function(resolve, reject) {
|
|
|
+ Page
|
|
|
+ .find({ creator: user._id, grant: GRANT_PUBLIC })
|
|
|
+ .sort({createdAt: -1})
|
|
|
+ .skip(offset)
|
|
|
+ .limit(limit)
|
|
|
+ .exec(function(err, pages) {
|
|
|
+ if (err) {
|
|
|
+ return reject(err);
|
|
|
+ }
|
|
|
+
|
|
|
+ return resolve(pages);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ pageSchema.statics.findListByStartWith = function(path, userData, option) {
|
|
|
+ var Page = this;
|
|
|
+
|
|
|
+ if (!option) {
|
|
|
+ option = {sort: 'updatedAt', desc: -1, offset: 0, limit: 50};
|
|
|
}
|
|
|
var opt = {
|
|
|
- sort: options.sort || 'updatedAt',
|
|
|
- desc: options.desc || -1,
|
|
|
- offset: options.offset || 0,
|
|
|
- limit: options.limit || 50
|
|
|
+ sort: option.sort || 'updatedAt',
|
|
|
+ desc: option.desc || -1,
|
|
|
+ offset: option.offset || 0,
|
|
|
+ limit: option.limit || 50
|
|
|
};
|
|
|
var sortOpt = {};
|
|
|
sortOpt[opt.sort] = opt.desc;
|
|
|
var queryReg = new RegExp('^' + path);
|
|
|
- var sliceOption = options.revisionSlice || {$slice: 1};
|
|
|
+ var sliceOption = option.revisionSlice || {$slice: 1};
|
|
|
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
var q = Page.find({
|