diff options
Diffstat (limited to 'models/pPost.js')
-rw-r--r-- | models/pPost.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/models/pPost.js b/models/pPost.js index 7181b69..c6def28 100644 --- a/models/pPost.js +++ b/models/pPost.js @@ -40,7 +40,8 @@ pPostSchema.statics = { .exec(callback); }, - /** + + /** * Find all posts that belong to a project, by project id * * @param {ObjectId} project @@ -53,6 +54,24 @@ pPostSchema.statics = { .populate('user') .sort({ 'when': -1 }) .exec(callback); + }, + + + /** + * Find last ten posts belonging projects a user is part of, by project ids + * + * @param {Array[ObjectId]} projects + * @param {Function} callback + * @api private + */ + + loadByProjects: function(projects, callback) { + this.find({ project: { $in: projects } }) + .populate({ path: 'user', select: 'name email status' }) + .populate({ path: 'project', select: 'name shortURL' }) + .limit(10) + .sort({ 'when': -1 }) + .exec(callback); } } |