DocumentDB LogoDocumentDB
HomeGitHubDiscordDocsBlogs
Back to DocumentationMQL Documentation
CommandsAggregationQuery And Write
OperatorsAccumulatorAggregationArithmetic ExpressionArray ExpressionArray QueryArray UpdateBitwiseBitwise QueryBitwise UpdateBoolean ExpressionComparison QueryConditional ExpressionData SizeDate ExpressionElement QueryEvaluation QueryField UpdateGeospatialLogical QueryMiscellaneousObject ExpressionProjectionSet ExpressionTimestamp ExpressionVariable ExpressionWindow
Reference/Operators/Conditional Expression

MongoDB Query Language (MQL) Conditional Expression Operators

$cond

The `$cond` operator is used to evaluate a condition and return one of two expressions based on the result. It's similar to the ternary operator in many programming languages.

$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.

Copyright © DocumentDB a Series of LF Projects, LLC. For web site terms of use, trademark policy and other project policies please see https://lfprojects.org.