Articles → MONGODB → $Elemmatch Operator In Mongodb$Elemmatch Operator In MongodbIn this article, we will discuss the $elemMatch operator in MongoDB.Purpose The $elemMatch operator is used to query the array elements.Example Consider the following example: -If you want to query the collection based on the name, the query will be: -db.authors.find({ "authors": { $elemMatch: { "name": "Jeff" } }})To query the collection based on the age, the query will be: -db.authors.find({ "authors": { $elemMatch: { "age": {$lt:30} } }})Posted By - Karan Gupta Posted On - Friday, March 15, 2024 Query/Feedback Your Email Id Subject Query/Feedback Characters remaining 250
db.authors.find({ "authors": { $elemMatch: { "name": "Jeff" } }})
db.authors.find({ "authors": { $elemMatch: { "age": {$lt:30} } }})
Query/Feedback