-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Practical MongoDB Aggregations
By :

An expression can be an operator (e.g., {$concat: ...}
), a variable (e.g., "$$ROOT"
), or a field path (e.g., "$address"
). In all these cases, an expression is just something that dynamically populates and returns a new element, which can be one of the following types:
However, a specific expression can restrict you to returning just one or a few of these types. For example, the {$concat: ...}
operator, which combines multiple strings, can only produce a string data type (or null). The "$$ROOT"
variable can only return an object that refers to the root document currently being processed in the pipeline stage.
A field path (e.g., "$address"
) is different and can return an element of any data type, depending on what the field refers to in the current input document....