fix increment to use data

v1.18.x
Barış Soner Uşaklı 7 years ago
parent baa868cf2b
commit 87d40e9e78

@ -83,8 +83,9 @@ module.exports = function (db, module) {
if (!key) {
return callback();
}
db.collection('objects').findAndModify({ _key: key }, {}, { $inc: { value: 1 } }, { new: true, upsert: true }, function (err, result) {
callback(err, result && result.value ? result.value.value : null);
db.collection('objects').findAndModify({ _key: key }, {}, { $inc: { data: 1 } }, { new: true, upsert: true }, function (err, result) {
console.log(result)
callback(err, result && result.value ? result.value.data : null);
});
};

@ -149,6 +149,21 @@ describe('Key methods', function () {
done();
});
});
it('should set then increment a key', function (done) {
db.set('myIncrement', 1, function (err) {
assert.ifError(err);
db.increment('myIncrement', function (err, value) {
assert.ifError(err);
assert.equal(value, 2);
db.get('myIncrement', function (err, value) {
assert.ifError(err);
assert.equal(value, 2);
done();
});
});
});
});
});
describe('rename', function () {

Loading…
Cancel
Save