Grokking MongoDB
Vote

0% completed

​

Logical Operators

How do you find the users who are younger than 25 or older than 35? One condition on age cannot say this, because no single value is both below 25 and above 35. You need two separate conditions and a rule for joining them, and that rule is a logical operator.

MongoDB has four logical operators.

OperatorReturns a document whenWritten as
$orAt least one condition is true{ $or: [ {...}, {...} ] }
$norNo condition is true{ $nor: [ {...}, {...} ] }
$andEvery condition is true`{ $and: [ {..

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content