- Reference >
- Operators >
- Aggregation Pipeline Operators >
- Aggregation Variable Operators >
- $map (aggregation)
$map (aggregation)¶
On this page
Definition¶
-
$map
¶ Applies an expression to each item in an array and returns an array with the applied results.
The
$map
expression has the following syntax:Field Specification input
An expression that resolves to an array. as
Optional. A name for the variable that represents each individual element of the input
array. If no name is specified, the variable name defaults tothis
.in
An expression that is applied to each element of the input
array. The expression references each element individually with the variable name specified inas
.For more information on expressions, see Expressions.