27
rated 0 times
[
28]
[
1]
/ answers: 1 / hits: 23077
/ 10 Years ago, fri, june 20, 2014, 12:00:00
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..
More From » node.js