From f2763fe7cf38a8ee09df4878e9b0d10212c5dc58 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Fri, 24 May 2013 09:49:59 +0200 Subject: made method to collect all users from a bunch of projects at the same time --- models/Access.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/models/Access.js b/models/Access.js index ab45b4c..75f6003 100644 --- a/models/Access.js +++ b/models/Access.js @@ -63,6 +63,23 @@ AccessSchema.statics = { .exec(callback); }, + + /** + * Load all users associated with several projects + * + * @param {Arrau[ObjectId]} projects + * @param {Function} callback + * @api private + */ + + loadProjects: function(projects, callback) { + this.find({ project: { $in: projects } }) + .populate({ path: 'user', select: 'name email status' }) + .sort({ 'created': -1 }) + .exec(callback); + }, + + /** * Check to see if user has access to a particular project * -- cgit v1.2.3