$concat (aggregation)
On this page
Definition
-
$concat
-
Concatenates strings and returns the concatenated string.
$concat
has the following syntax:The arguments can be any valid expression as long as they resolve to strings. For more information on expressions, see Expressions.
If the argument resolves to a value of
null
or refers to a field that is missing,$concat
returnsnull
.
Examples
Consider a inventory
collection with the following documents:
The following operation uses the $concat
operator to concatenate the item
field and the description
field with a ” - ” delimiter.
The operation returns the following results: