Articles → MONGODB → $Elemmatch Operator In Mongodb

$Elemmatch Operator In Mongodb






Purpose





Example




Picture showing the sample mongodb document




db.authors.find({ "authors": { $elemMatch: { "name": "Jeff" } }})


Picture showing using the $elemMatch for querying the collection based on name




db.authors.find({ "authors": { $elemMatch: { "age": {$lt:30} } }})


Picture showing using the $elemMatch for querying the collection based on age





Posted By  -  Karan Gupta
 
Posted On  -  Friday, March 15, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250