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




Picture showing the sample sales collection




db.sales.find({$and: [{ "product":"A"},{ "quantity":5}]})



Output


Picture showing the output of $and logical operator in mongodb





Posted By  -  Karan Gupta
 
Posted On  -  Saturday, February 24, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250