MongoDB Operators Reference

All MongoDB query, update, aggregation and projection operators in one table.

Searchable MongoDB operator reference covering query operators, update modifiers, aggregation pipeline stages and expressions, and projection operators — including $match, $group, $lookup, $set and $expr.

What is the difference between a query operator and an update operator?

Query operators like $gt and $in appear in the filter document and decide which documents match. Update operators like $set and $inc appear in the update document and decide how matched documents are modified.

Find the right MongoDB operator fast

MongoDB operators span several worlds: query operators that filter documents, update modifiers that change them, aggregation pipeline stages that transform a stream of documents, aggregation expressions that compute values, and projection operators that shape the output. This reference lets you search all of them by name or description and filter by category. It runs entirely in your browser.

How it works

Each entry shows the operator, its category and a short description, with an example for the most common ones. The category matters because the same $ name can behave differently depending on where it appears. A query filter, an update document and an aggregation pipeline each use their own operator set:

// query
db.orders.find({ total: { $gt: 100 }, status: { $in: ["paid", "shipped"] } })

// update
db.orders.updateOne({ _id: id }, { $set: { status: "paid" }, $inc: { tries: 1 } })

// aggregation
db.orders.aggregate([
  { $match: { status: "paid" } },
  { $group: { _id: "$customer", spent: { $sum: "$total" } } },
  { $lookup: { from: "users", localField: "_id", foreignField: "_id", as: "user" } }
])

Tips and examples

  • Put a $match as early as possible in a pipeline so it can use indexes and shrink the document stream before expensive later stages.
  • Use $expr to compare two fields in the same document inside find().
  • $elemMatch is required when you need several conditions to hold on the same array element rather than on the array as a whole.
  • $facet lets you compute several aggregations (e.g. results plus a total count) from one input in a single round trip.