From 978b8a4eb796e3eb2ee5430048830b0916f47d79 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Thu, 23 May 2013 14:27:13 +0200 Subject: added loadProject function that gets all posts that belong to that project --- models/pPost.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/models/pPost.js b/models/pPost.js index 6314757..7181b69 100644 --- a/models/pPost.js +++ b/models/pPost.js @@ -38,6 +38,21 @@ pPostSchema.statics = { this.findOne({ _id: id }) .populate('user') .exec(callback); + }, + + /** + * Find all posts that belong to a project, by project id + * + * @param {ObjectId} project + * @param {Function} callback + * @api private + */ + + loadProject: function(project, callback) { + this.find({ project: project }) + .populate('user') + .sort({ 'when': -1 }) + .exec(callback); } } -- cgit v1.2.3