- Reference >
- Operators >
- Aggregation Pipeline Operators >
- Group Accumulator Operators >
- $last (aggregation)
$last (aggregation)¶
On this page
Definition¶
-
$last¶ Returns the value that results from applying an expression to the last document in a group of documents that share the same group by a field. Only meaningful when documents are in a defined order.
$lastis an accumulator operator available only in the$groupstage.$lasthas the following syntax:For more information on expressions, see Expressions.