MongoDB Tutorial 0/120 lessons ~6 min read Lesson 33
Query Operators
MongoDB ships dozens of query operators that let you express anything SQL can — and more.
Course progress0%
Focus
5 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
MongoDB ships dozens of query operators that let you express anything SQL can — and more. They're grouped into comparison, logical, element, array, evaluation and geospatial categories.
Understanding the topic
- Comparison —
$eq, $ne, $gt, $gte, $lt, $lte, $in, $nin. - Logical —
$and, $or, $not, $nor. - Element —
$exists, $type. - Array —
$all, $elemMatch, $size. - Evaluation —
$regex, $expr, $mod, $jsonSchema.
Syntax reference
js
db.users.find({age: { $gte: 18 },$or: [ { city: "NYC" }, { city: "LA" } ],tags: { $all: ["pro", "verified"] },email: { $regex: /@example\.com$/i }});
Real-world use
Most application filters are 2-3 operators stacked — get fluent here.
Best practices
- Use
$ininstead of multiple$orbranches. - Prefer
$elemMatchfor multi-condition array filters.
Ready to mark this lesson complete?Track your journey across the entire course.