mongodb native driver issues on filter queries <p>I'm having trouble getting to use the query mongodb.</p> <p>I do not know if I could detail the method used is being sent an object, but is being rejected or sometimes the filter back empty.</p> <p>it always returns me an error:</p> <pre><code>MongoError: query selector must be an object </code></pre> <p>The entry of the query is being thereby:</p> <pre><code>{ filter: 'f', limit: '5', page: '1', sort: '-posted' } </code></pre> <p>My server Route:</p> <pre><code>exports.findAll = function(req, res, next) { var locals = {}, section = req.params.section, query = req.query, filter = {}; if(query.filter) { filter = query.filter.replace(/"(\w+)"\s*:/g, '$1:'); filter = filter.replace(/["]/g, "'"); } console.log(filter); delete query.filter; async.series([ function(callback) { MongoClient.connect(url, function(err, db) { if (err) return callback(err); locals.collection = db.collection(section); callback(); }); }, function(callback) { locals.collection.count(filter, function (err, result){ if (err) return callback(err); locals.count = result; callback(); }); }, function(callback) { //var cursor = locals.collection.find(filter); var cursor = locals.collection.find(filter, req.query); // if(req.query.order) { // cursor = cursor.sort(); // } // // if(req.query.limit) { // cursor = cursor.limit(Math.abs(req.query.limit)); // if(req.query.page) { cursor = cursor.skip(Math.abs(req.query.limit) * --req.query.page); } // } cursor.toArray(function(err, docs) { if (err) return callback(err); locals.docs = docs; callback(); }); } ], function(err) { //This function gets called after the three tasks have called their "task callbacks" if (err) return next(err); // Here locals will be populated with 'count' and 'docs' res.json({ count: locals.count, data: locals.docs }); }); </code></pre> <p>};</p> <p>i change the function server, adn now my response is:</p> <pre><code>{ filter: {situation: 't'}, limit: '5', page: '1', sort: '-posted' } </code></pre> <p>And same error :( :(</p>