simplified callback

v1.18.x
barisusakli 11 years ago
parent b0b78c3092
commit b4182f57fe

@ -136,14 +136,13 @@ module.exports = function(db, module) {
}; };
module.incrObjectFieldBy = function(key, field, value, callback) { module.incrObjectFieldBy = function(key, field, value, callback) {
callback = callback || function() {};
var data = {}; var data = {};
field = helpers.fieldToString(field); field = helpers.fieldToString(field);
data[field] = value; data[field] = value;
db.collection('objects').findAndModify({_key:key}, {}, {$inc: data}, {new:true, upsert:true}, function(err, result) { db.collection('objects').findAndModify({_key:key}, {}, {$inc: data}, {new:true, upsert:true}, function(err, result) {
if(typeof callback === 'function') { callback(err, result ? result[field] : null);
callback(err, result ? result[field] : null);
}
}); });
}; };
}; };

@ -125,11 +125,7 @@ module.exports = function(redisClient, module) {
multi[reverse ? 'zrevrange' : 'zrange']('temp', start, stop); multi[reverse ? 'zrevrange' : 'zrange']('temp', start, stop);
multi.del('temp'); multi.del('temp');
multi.exec(function(err, results) { multi.exec(function(err, results) {
if (!err && typeof callback === 'function') { callback(err, results ? results[1] : null);
callback(null, results[1]);
} else if (err) {
callback(err);
}
}); });
} }
}; };
Loading…
Cancel
Save