MongoDB $cond

In MongoDB, the $cond aggregation pipeline operator evaluates a boolean expression, and returns one of the two specified return expressions, depending on whether the boolean expression is true or false.

The $cond operator accepts two syntaxes: a longhand syntax and a shorthand syntax. Examples of each are below.

Continue reading