Skip to content
Justice Tech School

Comparison Operators

$eq, $ne, $gt, $gte, $lt, $lte, $in and $nin compare values. Combine several on one field for a range.

Example
db.students.find({ age: { $gte: 18, $lt: 30 } })
db.students.find({ city: { $in: ["Lagos", "Accra"] } })

Exercise

Greater than.

{ age: { $: 18 } }

Quiz Test

Which operator means in a list?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.