Skip to main content
Version: Next

Aggregation stages

Aggregation stages are a series of one or more processes in a pipeline that acts upon the returned result of the previous stage, starting with the input documents.

Supported aggregation stagesDescription
$countReturns the count of all matched documents in a specified query
$groupGroups documents based on specific value or expression and returns a single document for each group
$limitLimits specific documents and passes the rest to the next stage
$matchActs as a find operation by only returning documents that match a specified query to the next stage
$projectSpecifies the fields in a document to pass to the next stage in the pipeline
$skipSkips a specified n number of documents and passes the rest to the next stage
$sortSorts and returns all the documents based on a specified order
$unsetSpecifies the fields to be removed/excluded from a document
$unwindDeconstructs and returns a document for every element in an array field