im trying to do a findAndModifiy in mongodb with nodejS, This is my code:
var nextBill = function (db, success, log) {
var collection = db.collection(\'
http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#findAndModify
This above document specifies that the second parameter is the sort order for choosing which document to use if multiple ones match the query. Only giving two parameters will result in the "need remove or update" error message.
collection('MyCollection').findAndModify(
{ _id: "auto" },
[],
{ $inc: { "bill": 1 } },
{ upsert: true, new: true },
function(err,doc) {
// work here
}
);