MongoDB Query Operators
Filtering and querying documents
Comparison Operators
$eq # equal
$ne # not equal
$gt # greater than
$gte # greater than or equal
$lt # less than
$lte # less than or equal
$in # in array
$nin # not in array
Logical Operators
db.users.find({ $and: [{ age: { $gt: 18 } }, { country: 'USA' }] }); # AND
db.users.find({ $or: [{ age: 25 }, { name: 'John' }] }); # OR
db.users.find({ age: { $not: { $gt: 18 } } }); # NOT
Element Operators
db.users.find({ email: { $exists: true } }); # field exists
db.users.find({ age: { $type: 'number' } }); # check type
Array Operators
db.users.find({ tags: { $all: ['javascript', 'mongodb'] } }); # contains all
db.users.find({ tags: { $size: 3 } }); # array size
db.users.find({ tags: 'mongodb' }); # array contains value
Regex
db.users.find({ name: { $regex: 'john', $options: 'i' } }); # case-insensitive match