diff options
-rw-r--r-- | models/pPost.js | 15 |
1 files changed, 15 insertions, 0 deletions
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); } } |