- Reference >
- Operators >
- Aggregation Pipeline Operators >
- $ifNull (aggregation)
$ifNull (aggregation)¶
On this page
Definition¶
-
$ifNull
¶
Changed in version 5.0.
The $ifNull
expression evaluates input expressions for
null values and returns:
- The first non-null input expression value found.
- A replacement expression value if all input expressions evaluate to null.
$ifNull
treats undefined values and missing fields as
null.
Syntax:
In MongoDB 4.4 and earlier versions, $ifNull
only
accepts a single input expression: