aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-05-23 14:27:13 +0200
committerDennis Eriksen <dennis.se@gmail.com>2013-05-23 14:27:13 +0200
commit978b8a4eb796e3eb2ee5430048830b0916f47d79 (patch)
treeacc742d70906b69ad06aa472865b1beb28ae00d7
parentupdate status of user when mail is entered (diff)
downloadDivid-978b8a4eb796e3eb2ee5430048830b0916f47d79.tar.gz
added loadProject function that gets all posts that belong to that
project
-rw-r--r--models/pPost.js15
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);
}
}