node.js - findAndModify Error in mongodb - nodejs - error code 17287 -


i getting following error :

mongoerror: exception: nextsafe(): { $err: "can't canonicalize query: b advalue bad sort specification", code: 17287 }

functions.getnextindex = function(callback){      db.collection('counters').findandmodify(             {_id:'productid'},             {$inc: {sequence_value:1}},              function(err,data){                 if(!err)                     callback(data);                 else                     callback(err);     });  } 

it seems missing "sort" argument in query.

try like:

db.collection('counters').findandmodify(     {_id:'productid'},     {_id:'descending'},     {$inc: {sequence_value:1}},      function(err,data){         if(!err)             callback(data);         else             callback(err); }); 

see more here: http://docs.mongodb.org/manual/reference/method/db.collection.findandmodify/


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -