Conditional Operators

OperatorDescriptionExample
$condTakes an array of 3 expressions. If the first expression evaluates to true, the second expression value is returned. Otherwise, the value of the third expression is returned.{“$cond”: [“c_active”, {“$string”: “active”}, {“$string”: “inactive”}]}
$ifNullTakes an array of 2 expressions. Returns the value of the first expression unless it evaluates to null, in which case the value of the second expression is returned.{“$ifNull”: [“c_offset”, {“$integer”: 42}]}