Comparison, logical, and array operators. Projection, sort, skip, and limit.
// Numeric comparisons
db.products.find({ price: { $gt: 100 } }) // > 100
db.products.find({ price: { $gte: 100 } }) // >= 100
db.products.find({ price: { $lt: 50 } }) // < 50
db.products.find({ price: { $ne: 0 } }) // != 0
db.products.find({ category: { $in: ['Electronics', 'Books'] } })
db.products.find({ category: { $nin: ['Food'] } })// AND (implicit — just combine conditions)
db.products.find({ price: { $lt: 100 }, inStock: true })
// Explicit AND
db.products.find({ $and: [
{ price: { $lt: 100 } },
{ category: 'Electronics' }
]})
// OR
db.products.find({ $or: [
{ price: { $lt: 10 } },
{ featured: true }
]})
// NOT
db.products.find({ category: { $not: { $eq: 'Food' } } })// Projection: 1 = include, 0 = exclude
db.products.find({}, { name: 1, price: 1, _id: 0 })
// Sort: 1 = ascending, -1 = descending
db.products.find().sort({ price: -1 })
// Pagination
const PAGE = 2;
const PER_PAGE = 10;
db.products.find()
.sort({ createdAt: -1 })
.skip((PAGE - 1) * PER_PAGE)
.limit(PER_PAGE)$gt, $gte, $lt, $lte, $ne, $in, $nin.$and (implicit with multiple conditions), $or, $not.{ field: 1 } to include, { field: 0 } to exclude. Can't mix include/exclude..sort().skip().limit() chain for pagination.