added sortedSetIncrBy

This commit is contained in:
barisusakli
2014-09-27 15:48:16 -04:00
parent 99d98a7016
commit 9d25772b53
3 changed files with 22 additions and 0 deletions

View File

@@ -410,4 +410,18 @@ module.exports = function(db, module) {
callback(null, data);
});
}
module.sortedSetIncrBy = function(key, increment, value, callback) {
callback = callback || helpers.noop;
if (!key) {
return callback();
}
var data = {};
value = helpers.fieldToString(value);
data['score'] = parseInt(increment, 10);
db.collection('objects').findAndModify({_key: key, value: value}, {}, {$inc: data}, {new:true, upsert:true}, function(err, result) {
callback(err, result ? result[value] : null);
});
};
};