- Reference >
- Operators >
- Aggregation Pipeline Operators >
- $push (aggregation)
$push (aggregation)¶
On this page
Definition¶
-
$push¶ Returns an array of all values that result from applying an expression to each document in a group of documents that share the same group by key.
$pushis only available in the$groupstage.$pushhas the following syntax:For more information on expressions, see Expressions.
Example¶
Consider a sales collection with the following documents:
Grouping the documents by the day and the year of the date field,
the following operation uses the $push accumulator to
compute the list of items and quantities sold for each group:
The operation returns the following results: