Articles → MONGODB → $And Logical Operator In Mongodb
$And Logical Operator In Mongodb
Purpose
 
Syntax
 
db.collection.find({
    $and: [
        { condition1 },
        { condition2 },
        { condition3 },
        // More conditions if needed
    ]
})
Example
 
db.sales.find({$and: [{ "product":"A"},{ "quantity":5}]})
Output
 
| Posted By  - | Karan Gupta | 
|  | 
| Posted On  - | Saturday, February 24, 2024 |