Aggregation expression categories
standardintermediateAggregation expressions are the functions you use inside $project, $set, $group and other stages to compute a value from a document's fields, instead of just copying them through. They are grouped by what they work on: numbers, comparisons, strings, dates, arrays, and so on.
Think of it as
Think of expressions as the formula language of the pipeline — the same role a spreadsheet formula plays over a row. A stage says which documents to touch; an expression says how to compute one field's new value from the others.
What we're doing: Compute a line-item total and a display label from raw fields, in one $set stage.
- 2
- $multiply takes an array of expressions and multiplies them — here, two field references.
- 3
- $concat only accepts strings, so $toString converts the numeric quantity before joining it in.
Why this works: Expressions compose the same way normal function calls do — an expression can be another expression's argument, which is how one $set stage builds several derived fields from the same raw data.
Expression families and where each is used
Together
Remember: Expression operators ($add, $concat, $gt, …) are the pipeline's formula language — they compute a value inside a stage, and nest inside each other like function calls.
See also: cond ifnull switch · map filter reduce

