jBoive
jBoive

Reputation: 1299

Finding an object in MongoDb that has a value within a range

MongoDb 3.4.9

I have objects that look like this:

startIpNum:16779264
endIpNum:16781311
locId:47667

startIpNum:16781312
endIpNum:16785407
locId:879228

etc

How can I find just the object that has a range (between startIpNum and endIpNum) for 16779300?

Upvotes: 0

Views: 33

Answers (1)

Simran
Simran

Reputation: 2810

db.collection.find({ startIpNum:{ $gte: 16779300 }, endIpNum:{$lte: 16779300} })

It includes both upper and lower limit

Upvotes: 1

Related Questions