MongoDB Query Language (MQL) Conditional Expression Operators
Conditional expression operators evaluate conditions and return different values based on the evaluation results. These operators enable if-then-else logic within aggregation expressions, allowing you to perform conditional transformations and computations based on field values or expressions.
$cond
The $cond operator is used to evaluate a condition and return one of two expressions based on the result.
$ifNull
The $ifNull operator is used to evaluate an expression and return a specified value if the expression resolves to null.
$switch
The $switch operator is used to evaluate a series of conditions and return a value based on the first condition that evaluates to true.