- Reference >
- Database Commands >
- Aggregation Commands >
- aggregate
aggregate¶
-
aggregate¶ New in version 2.1.0.
aggregateimplements the aggregation framework. Consider the following prototype form:Where
[collection]specifies the name of the collection that contains the data that you wish to aggregate. Thepipelineargument holds an array that contains the specification for the aggregation operation. Consider the following example.More typically this operation would use the
aggregate()helper in themongoshell, and would resemble the following:Changed in version 2.4: If an error occurs, the
aggregate()helper throws an exception. In previous versions, the helper returned a document with the error message and code, andokstatus field not equal to1, same as theaggregatecommand.For more information about the aggregation pipeline Aggregation Pipeline and Aggregation Reference.