im trying to do a findAndModifiy in mongodb with nodejS, This is my code:
var nextBill = function (db, success, log) {
var collection = db.collection(\'
Hi I have followed this and it worked perfectly.
db.collection('test').findAndModify(
{hello: 'world'}, // query
[['_id','asc']], // sort order
{$set: {hi: 'there'}}, // replacement, replaces only the field "hi"
{}, // options
function(err, object) {
if (err){
console.warn(err.message); // returns error if no matching object found
}else{
console.dir(object);
}
});
});