Conditional Operators in MOngo db c#.net

IN sql query we are familiar in this conditional operator

<, <=, >, >=


IN mongo db json we have to write

db.collection.find({ "field" : { $gt: value } } );   // greater than  : field > value
db.collection.find({ "field" : { $lt: value } } );   // less than  :  field < value
db.collection.find({ "field" : { $gte: value } } );  // greater than or equal to : field >= value
db.collection.find({ "field" : { $lte: value } } );  // less than or equal to : field <= 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 } } );    // value1 < field < value
Ebook Download
View all
Learn
View all