Aggregation expressions explained
Aggregation expressions provide syntax and a library of commands to allow you to perform sophisticated data operations within many of the stages you include in your aggregation pipelines. You can use expressions within the pipeline to perform tasks such as the following:
- Compute values (e.g., calculate the average value of an array of numbers)
- Convert an input field's value (e.g., a string) into an output field's value (e.g., a date)
- Extract the specific reoccurring field's value from an array of sub-documents into a new list of values
- Transform the shape of an input object into an entirely differently structured output object
In many cases, you can nest expressions within other expressions, enabling a high degree of sophistication in your pipelines, albeit sometimes at the cost of making your pipelines appear complex.
You can think of an aggregation expression as being one of three possible types:
-
...