Element operators test the shape of a document: $exists checks field presence, $type checks the BSON type.
db.users.find({ phone: { $exists: false } })
db.items.find({ qty: { $type: "string" } }) // find bad data!Array operators
$all requires every listed value to be present; $size matches exact array length; $elemMatch requires a *single element* to satisfy all conditions at once.
db.products.find({ tags: { $all: ["wireless", "audio"] } })
db.products.find({ tags: { $size: 2 } })
// one grade element must be both subject math AND score > 90
db.students.find({
grades: { $elemMatch: { subject: "math", score: { $gt: 90 } } }
})Why $elemMatch matters
Without it, { "grades.subject": "math", "grades.score": { $gt: 90 } } can match a document where *one* element has subject math and a *different* element has score > 90 — a classic bug.
Regex
$regex (or a /pattern/ literal) performs pattern matching on strings. Anchored prefixes like /^Wire/ can use an index; unanchored patterns cannot.
db.products.find({ name: { $regex: "^Wire" } })