What does $and do?
$and is a logical operator that selects documents satisfying every condition at once.
Example:
js
db.users.find({
$and: [
{ age: { $gt: 18 } },
{ isActive: true }
]
})This query returns only documents where age is greater than 18 and isActive is true.
The gist of it: $and is a logical "AND" across several conditions.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.