Skip to main content
Ganesh Joshi
Back to Cheatsheets

MongoDB queries

Updated 2026-02-15

find, findOne, aggregate, update, delete. Filter operators, projection, and indexes.

find and findOne

db.coll.find({}) all. find({ name: 'x' }). find({ age: { $gt: 18 } }). $gt, $gte, $lt, $lte, $in, $nin, $exists, $regex. Projection: find({}, { name: 1, _id: 0 }).

update and aggregate

updateOne/updateMany({ filter }, { $set: { ... } }). $push, $pull for arrays. aggregate([ { $match }, { $group: { _id: '$x', count: { $sum: 1 } } }, { $sort } ]).

MongoDB queries | Cheatsheet | Ganesh Joshi