- 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
$mapexpression has the following syntax:Field Specification inputAn expression that resolves to an array. asOptional. A name for the variable that represents each individual element of the inputarray. If no name is specified, the variable name defaults tothis.inAn expression that is applied to each element of the inputarray. The expression references each element individually with the variable name specified inas.For more information on expressions, see Expressions.