Find Operations
Find documents
Find only one document
With equality
With $in operator
Finding Documents by Using Comparison Operators
$gt
- Greater than$lt
- Less than$gte
- Greater or equal than$lte
- Less or equal than
Quering on array elements
Find Documents with an Array That Contains a Specified Value
Matches any document where the products field is an array and "InvestmentFund" is an element in that array.
Find a Document using $elemMatch
Matches any document that contains a item in that field that validates all the conditions.
db.sales.find({
items: {
$elemMatch: { name: "laptop", price: { $gt: 800 }, quantity: { $gte: 1 } },
},
})