- 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. asThe variable name for the items in the inputarray. Theinexpression accesses each item in theinputarray by this variable.inThe expression to apply to each item in the inputarray. The expression accesses the item by its variable name.For more information on expressions, see Expressions.