Created
March 22, 2014 11:05
-
-
Save A/9705337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function () { | |
var ObjectId = mongoose.Schema.ObjectId; | |
return function (req, res) { | |
mongoose | |
.model('Project') | |
.aggregate({ | |
'$match': { | |
'pages.texts._id': ObjectId(req.params.componentID) | |
} | |
}) | |
.unwind('$pages') | |
.unwind('$pages.texts') | |
.aggregate({ | |
'$match': { | |
'pages.texts._id': ObjectId(req.params.componentID) | |
} | |
}) | |
.group({ | |
'_id': '$_id', | |
'texts': { | |
'$push': '$pages.texts' | |
} | |
}) | |
.exec(function (err, res) { | |
console.log(err); | |
console.log(res); | |
}); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment