How to use greater than queries in mongodb
In this tutorial, we will query mongodb for states where the high temperature is greater than 100 and less than 110 Fahrenheit.
The data that we are querying from in MongoLab looks like this in the firstdb database in the highlowtemp collection …
We continue from last tutorial here but changing things slightly…
In our query object, we use the ‘$gt’ and ‘$lt’ operator. Passing the query object in our find() method, we call the each() method and output the returned records.
Note also how we used dot-notion in “high.fahrenheit” to access a field nested within the data object.