1. Match either
$or takes an array of conditions and matches a document satisfying at least one of them.
$or: [{ age: { $lt: 18 } }, { vip: true }]Typorithm · medium
Step 1 of 8 · intro card
Query Operators
Logical operators combine conditions: $or matches any, $and matches all, $nor matches none, and $exists checks whether a field is present.
$or accepts an array of clauses and matches a document satisfying at least one of them.
$and is implicit between separate fields, but explicit $and is needed when one field must satisfy two conditions; $nor is the negation of $or.
$exists tests presence: $exists: true keeps documents that have the field, $exists: false keeps those that lack it.
$or matches any clause; $and matches every clause.
$nor matches documents satisfying none of the clauses.
$exists checks field presence, not its value.
db.users.find({ $or: [{ age: { $lt: 18 } }, { vip: true }] })
db.users.find({ $and: [{ active: true }, { age: { $gte: 21 } }] })
db.users.find({ email: { $exists: true } })
db.users.find({ $nor: [{ banned: true }, { deleted: true }] })Connect each part of the code to the concept before you type.
$or takes an array of conditions and matches a document satisfying at least one of them.
$or: [{ age: { $lt: 18 } }, { vip: true }]$and requires every condition in the array to hold — useful when the same field appears twice.
$and: [{ active: true }, { age: { $gte: 21 } }]$exists: true matches documents that have the field at all, regardless of its value.
{ $exists: true }$nor matches documents that satisfy none of the listed conditions — the negation of $or.
$nor: [{ banned: true }, { deleted: true }]Read the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.