NodeJS + MongoDB: find() where { 'value' : < 5 AND >1} - how?

database, mongodb, node.js

Solution

There is an example in the docs for Advanced Queries that's exactly what you want:

db.collection.find({ "field" : { $gt: value1, $lt: value2 } } );    // value1 < field < value

Problem

I have a collection "companies". Every object in this collection has "lastcall"-param. It's a simple string, containing UNIX time of the last call. I'd like to find all the companies, where lastcall is higher than a AND lower than b. How can I do this? Here's the code I use to access to compnaies: ``` //query to lastcall collection.find( {'lastcall': a} , function (err, companies) { companies.each(function (err, company) { //do something with every object... }); }); ``` This code will return all the companies where 'lastcall' = A, but I need all the ones where A < 'lastcall' < B. How can I do this? Thanks!

Original source