IN sql query we are familiar in this conditional operator
<, <=, >, >=
IN mongo db json we have to write
- db.collection.find({ "field" : { $gt: value } } );
- db.collection.find({ "field" : { $lt: value } } );
- db.collection.find({ "field" : { $gte: value } } );
- db.collection.find({ "field" : { $lte: value } } );
For example
- db.things.find({j : {$lt: 3}});
- db.things.find({j : {$gte: 4}});
You can also combine these operators to specify ranges:
- db.collection.find({ "field" : { $gt: value1, $lt: value2 } } );