Introduction
Query operators help us find exactly the data we want from a big collection by setting clear rules for searching.
Jump into concepts and practice - no test required
{ field: { $operator: value } }{ age: { $gt: 30 } }{ name: { $in: ["Alice", "Bob"] } }{ score: { $exists: true } }db.students.find({ age: { $gte: 18 } })$gt or $lt in MongoDB queries?$gt (greater than) and $lt (less than) let us specify these conditions inside queries.{ age: { $gt: 30 } } which is the correct syntax for 'age greater than 30'. Others miss the $ or use invalid syntax.users with documents: db.users.find({ age: { $gt: 28 } }) return?db.users.find({ age: $lt: 40 }){ age: { $lt: 40 } }. The given query misses the curly braces around the operator.{ price: { $gte: 50, $lte: 100 } }.