im trying to do a findAndModifiy in mongodb with nodejS, This is my code:
var nextBill = function (db, success, log) {
var collection = db.collection('autoincrements');
log.debug('autoIncrementRepository', 'nextBill');
var result = collection.findAndModify({
query: { _id: 'auto' },
update: { $inc: { bill: 1 } },
new: true
});
success(result.bill);
};
EDIT:
Try with callback
collection.findAndModify({
query: { _id: 'auto' },
update: { $inc: { bill: 1 } },
new: true
}, function (e, result) {
success(result.budget);
});
But give me the error need remove or update..But im doing it..
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…