1.0.5 • Published 8 years ago
mongo-aggregator v1.0.5
npm i mongo-aggregator
There are three methods:
expander.expandOne(childPath, projection, childCollectionName) for expand simple (not array) field.
expander.expandMany(childPath, projection, childCollectionName) for expand array field.
expander.expandManyWithChildProjection = function (childPathName, projection, childProjection, childCollectionName) for expand array field with projection for child documents.
A result of functions will be aggregation obj. Next: // mongoose MyModel.aggregate(aggregationObj, function(err, myModels) { ... }); // or mongo driver db.collection('myCollection').aggregate(aggregationObj, function(err, myDocs) { ... });