MongoDB 8 · Query and update operators
Match inside an array
Find orders with a line item that satisfies several conditions together.
db.orders.find({ items: { $elemMatch: { sku: "A1", qty: { $gte: 2 } } } })
Official MongoDB 8 documentation
More query and update operators commands
- Match any of several values
- Combine conditions with OR
- Search with a regular expression
- Check that a field exists
- Add to an array
- Remove from an array
All query and update operators commands · MongoDB 8 cheatsheet