Arshpreet Wadehra
Arshpreet Wadehra

Reputation: 1023

Check given number lies between range as defined inside mongodb document

Let say I have a collection with schema

{
  _id:ObjectId("xx")
  bound:{min:123,max:999}
}

I have a number let say 200 i want return result which accept the condition of bound i.e. for 200 it should return object like as mention above.

I need a query to get required results.

Thank you.

Upvotes: 1

Views: 455

Answers (1)

Arshpreet Wadehra
Arshpreet Wadehra

Reputation: 1023

Here i found solution with given number 200 test within bounds.

db.collection("test").find({$and:[{"bound.max":{$gt:200}},{"bound.min":{$lt:200}}]})

Upvotes: 1

Related Questions