Reputation: 932
In MySql we can query like following to retrieve the data between _min and _max
select * from dummy_table where 10 BETWEEN _min AND _max;
Here is my mongo db data
{ "_id" : ObjectId("5a670cc6450867d5bf85f63e"), "code" : "S1",
"_min" : 5, "_max" : 12 }
{ "_id" : ObjectId("5a670cda450867d5bf85f63f"), "code" : "S2",
"_min" : 12, "_max" : 20 }
I need to query like MySql equivalent for mongodb
Please suggest on this
Thank you.
Upvotes: 0
Views: 130
Reputation: 14476
The following will work
db.test.find({"_min": {$lte:10}, "_max" :{$gte: 10}})
Upvotes: 1