Aggregate constructor used for building aggregation pipelines.
Aggregate constructor used for building aggregation pipelines.
aggregation operator(s) or operator array
a new Aggregate instance
new Aggregate([{ $project: { a: 1, b: 1 } }, { $skip: 5 }]);
new Aggregate({ $project: { a: 1, b: 1 } }, { $skip: 5 });
new Aggregate({ $project: { a: 1, b: 1 } });
new Aggregate();
Adds a cursor flag
Adds a cursor flag
the flag
the value
Sets the allowDiskUse option for the aggregation query (ignored for < 2.6.0)
Sets the allowDiskUse option for the aggregation query (ignored for < 2.6.0)
Should tell server it can use hard drive to store data during aggregation.
optional tags for this query
Appends new operators to this aggregate pipeline
Appends new operators to this aggregate pipeline
the operator(s) to append
Adds a collation
Adds a collation
the collation options
the boolean indicator
Sets the cursor option option for the aggregation query (ignored for < 2.6.0).
Sets the cursor option option for the aggregation query (ignored for < 2.6.0). Note the different syntax below: .exec() returns a cursor object, and no callback is necessary.
the set the cursor batch size
var cursor = Model.aggregate(..).cursor({ batchSize: 1000 }).exec(); cursor.each(function(error, doc) { // use doc });
Execute the aggregation with explain
Execute the aggregation with explain
the callback
a promise of the results
Combines multiple aggregation pipelines.
Combines multiple aggregation pipelines.
the options
Appends new custom $graphLookup operator(s) to this aggregate pipeline, performing a recursive search on a collection.
Appends new custom $graphLookup operator(s) to this aggregate pipeline, performing a recursive search on a collection. Note that graphLookup can only consume at most 100MB of memory, and does not allow disk use even if { allowDiskUse: true } is specified.
to $graphLookup as described in the above link
Appends a new custom $group operator to this aggregate pipeline.
Appends a new custom $group operator to this aggregate pipeline.
the $group operator contents
Appends a new $limit operator to this aggregate pipeline.
Appends a new $limit operator to this aggregate pipeline.
the maximum number of records to pass to the next stage
Appends new custom $lookup operator(s) to this aggregate pipeline.
Appends new custom $lookup operator(s) to this aggregate pipeline.
to $lookup as described in the above link
Appends a new custom $match operator to this aggregate pipeline.
Appends a new custom $match operator to this aggregate pipeline.
the $match operator contents
Binds this aggregate to a model.
Binds this aggregate to a model.
the model to which the aggregate is to be bound
the Aggregate
Appends a new $geoNear operator to this aggregate pipeline.
Appends a new $geoNear operator to this aggregate pipeline. NOTE: MUST be used as the first operator in the pipeline.
the given parameters
Appends a new $project operator to this aggregate pipeline.
Appends a new $project operator to this aggregate pipeline.
the field specification
the Aggregate
Sets the readPreference option for the aggregation query.
Sets the readPreference option for the aggregation query.
one of the listed preference options or their aliases
optional tags for this query
the Aggregate
Appepnds new custom $sample operator(s) to this aggregate pipeline.
Appepnds new custom $sample operator(s) to this aggregate pipeline.
the number of random documents to pick
the Aggregate
Appends a new $skip operator to this aggregate pipeline.
Appends a new $skip operator to this aggregate pipeline.
the number of records to skip before next stage
the Aggregate
Appends a new $sort operator to this aggregate pipeline.
Appends a new $sort operator to this aggregate pipeline.
the sorting arguments
the Aggregate
aggregate.sort('field -test');
aggregate.sort({ field: 'asc', test: -1 });
Provides promise for aggregate.
Provides promise for aggregate.
the success callback
the error callback
a promise
Model.aggregate(..).then(successCallback, errorCallback);
Appends new custom $unwind operator(s) to this aggregate pipeline.
Appends new custom $unwind operator(s) to this aggregate pipeline.
Note that the $unwind operator requires the path name to start with '$'. Mongoose will prepend '$' if the specified field doesn't start '$'.
the field(s) to unwind
the Aggregate
Mongoose Aggregate
http://mongoosejs.com/docs/api.html#aggregate_Aggregate