node.js - mongoose query not working -


i trying run query in mongodb using mongoose :

mongoosemodel.find().where(query).exec(function (err, data) {

});

and value of query :

{ plate: 'bcf 5579', fuel_level: { $lte: 20 }}

in mongodb log, the query going empty ({}).

if replace query actual value this:

mongoosemodel.find().where({ plate: 'bcf 5579', fuel_level: { $lte: 20 }}).exec(function (err, data) {

});

it work. what's wrong first option?

here full code :

this.findallbycondition = function (query, options, callback) {             locallogger.debug('findallbycondition');             try {                  var sortby = "_id";  // default sort order                  var pagingoptions = {                     skip: 0,                     limit: 30                 };                  if (options && options.limit) {                     pagingoptions.limit = options.limit;                 }                 if (options && options.skip) {                     pagingoptions.skip = options.skip;                 }                  if (options && options.sortby) {                     sortby = options.sortby;                 }                  if (options && options.sortorder && options.sortorder === "desc") {                     sortby = "-" + sortby;                 }                   //{ plate: 'bcf 5579', fuel_level: { $lte: 20 }};                  //query1 = query;                  //query = req.query['q'];                  //var query1 = { plate: 'bcf 5579', fuel_level: { $lte: 20 }}                   var totalrecords = null;                 var results = null;                 async.parallel(                     [                         function (callback) {                             mongoosemodel.find(query).skip(pagingoptions.skip).limit(pagingoptions.limit).sort("field " + sortby).exec(function (err, data) {                                 if (err) {                                     callback(err);                                 }                                 else {                                     results = data;                                     callback();                                 }                             });                         },                         function (callback) {                             mongoosemodel.count(query, function (err, count) {                                 if (err) {                                     callback(err);                                 }                                 else {                                     totalrecords = count;                                     callback();                                 }                             });                         }                     ],                     function (err) {                         callback(err, results, totalrecords);                     }                 );             } catch (exception) {                 locallogger.error('exception while trying findone ' + exception.message + " stack:" + exception.stack);                 callback(exception, null);             }          }, 


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -