Q10: How do logical query operators ($and, $or, $nor, $not) work?
Logical operators join multiple clause conditions:
$or: Returns documents matching at least one clause:{ $or: [{ role: 'admin' }, { points: { $gt: 100 } }] }.$and: Joins conditions implicitly or explicitly when querying the same field multiple times.$nor: Returns documents failing all listed conditions.
Key Takeaways
Implicit
$andoccurs when comma-separating conditions in a query object.Use explicit
$andwhen targeting the same operator key multiple times.
Knowledge Check
When is an explicit $and operator required in a MongoDB query?