|
@@ -233,6 +233,29 @@ module.exports = function(crowi) {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ pageSchema.statics.findListByPageIds = function(ids) {
|
|
|
|
|
+ var Page = this;
|
|
|
|
|
+
|
|
|
|
|
+ debug('findPageByIds', ids);
|
|
|
|
|
+
|
|
|
|
|
+ return new Promise(function(resolve, reject) {
|
|
|
|
|
+ Page.find({
|
|
|
|
|
+ _id: {$in: ids},
|
|
|
|
|
+ }).populate([
|
|
|
|
|
+ {path: 'creator', model: 'User'},
|
|
|
|
|
+ {path: 'revision', model: 'Revision'},
|
|
|
|
|
+ ]).exec(function(err, docs) {
|
|
|
|
|
+ debug('findPagesByIds', err, docs);
|
|
|
|
|
+
|
|
|
|
|
+ if (err) {
|
|
|
|
|
+ return reject(err);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return resolve(docs);
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
pageSchema.statics.findPageByIdAndGrantedUser = function(id, userData, cb) {
|
|
pageSchema.statics.findPageByIdAndGrantedUser = function(id, userData, cb) {
|
|
|
var Page = this;
|
|
var Page = this;
|
|
|
|
|
|
|
@@ -265,7 +288,27 @@ module.exports = function(crowi) {
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- pageSchema.statics.findListByPageIds = function(ids, options, cb) {
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Bulk get (for internal only)
|
|
|
|
|
+ */
|
|
|
|
|
+ pageSchema.statics.getStreamOfFindAll = function(options) {
|
|
|
|
|
+ var Page = this
|
|
|
|
|
+ , options = options || {}
|
|
|
|
|
+ , publicOnly = options.publicOnly || true
|
|
|
|
|
+ , criteria = {redirectTo: null,}
|
|
|
|
|
+ ;
|
|
|
|
|
+
|
|
|
|
|
+ if (publicOnly) {
|
|
|
|
|
+ criteria.grant = GRANT_PUBLIC;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return this.find(criteria)
|
|
|
|
|
+ .populate([
|
|
|
|
|
+ {path: 'creator', model: 'User'},
|
|
|
|
|
+ {path: 'revision', model: 'Revision'},
|
|
|
|
|
+ ])
|
|
|
|
|
+ .sort({updatedAt: -1})
|
|
|
|
|
+ .stream();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
pageSchema.statics.findListByStartWith = function(path, userData, options, cb) {
|
|
pageSchema.statics.findListByStartWith = function(path, userData, options, cb) {
|