upsert for redis

This commit is contained in:
Anatoliy Chakkaev 2012-03-23 00:33:09 +04:00
parent 95c0e7d5d0
commit 29afdff4dc
1 changed files with 5 additions and 0 deletions

View File

@ -97,6 +97,11 @@ BridgeToRedis.prototype.create = function (model, data, callback) {
}
};
BridgeToRedis.prototype.updateOrCreate = function (model, data, callback) {
if (!data.id) return this.create(model, data, callback);
this.save(model, data, callback);
};
BridgeToRedis.prototype.exists = function (model, id, callback) {
var log = this.logger('EXISTS ' + model + ':' + id);
this.client.exists(model + ':' + id, function (err, exists) {