- Reference >
- Operators >
- Aggregation Pipeline Operators >
- Boolean Aggregation Operators >
- $or (aggregation)
$or (aggregation)¶
On this page
Definition¶
-
$or¶ Evaluates one or more expressions and returns
trueif any of the expressions aretrue. Otherwise,$orreturnsfalse.$orhas the following syntax:For more information on expressions, see Expressions.
Behavior¶
$or uses short-circuit logic: the operation stops
evaluation after encountering the first true expression.
In addition to the false boolean value, $or evaluates
as false the following: null, 0, and undefined
values. The $or evaluates all other values as true,
including non-zero numeric values and arrays.
| Example | Result | |
|---|---|---|
{ $or: [ true, false ] } |
true |
|
{ $or: [ [ false ], false ] } |
true |
|
{ $or: [ null, 0, undefined ] } |
false |
|
{ $or: [ ] } |
false |