- 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.
$push
is only available in the$group
stage.$push
has 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: