mongo-aggregator
v1.0.5
Published
Creates aggregation object for get documents with relations from mongo db.
Downloads
5
Readme
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) { ... });