added sortedSetIncrBy

v1.18.x
barisusakli 10 years ago
parent 99d98a7016
commit 9d25772b53

@ -292,4 +292,8 @@ module.exports = function(db, module) {
callback(null, returnData);
});
}
module.sortedSetIncrBy = function(key, increment, value, callback) {
throw new Error('not implemented');
};
};

@ -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);
});
};
};

@ -211,4 +211,8 @@ module.exports = function(redisClient, module) {
callback(err, results ? results[1] : null);
});
}
module.sortedSetIncrBy = function(key, increment, value, callback) {
redisClient.zincrby(key, increment, value, callback);
};
};
Loading…
Cancel
Save