Let\'s borrow the excellent example from scaryguy with modification as below:
Project Group Schema:
var ProjectGroupSchema = new Schema({
project
You can achieve this by using aggregate function. First group projects by "projectGroup" and then populate result.
project.aggregate([
{$group: {_id: "$group", projects: {$push: "$$ROOT"}}}
],
function(err,results) {
user.populate( results, { "path": "projects.subscribers" }, function(err,results) {
if (err)
console.log(err);
res.send(results);
});
});