Richardson. M
Richardson. M

Reputation: 932

MySQL equivalent mongo query


  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

Answers (1)

Kevin Smith
Kevin Smith

Reputation: 14476

The following will work

 db.test.find({"_min": {$lte:10}, "_max" :{$gte: 10}})

Upvotes: 1

Related Questions