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) {
callback = callback || function() {};
var data = {};
field = helpers.fieldToString(field);
data[field] = value;
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.del('temp');
multi.exec(function(err, results) {
if (!err && typeof callback === 'function') {
callback(null, results[1]);
} else if (err) {
callback(err);
}
callback(err, results ? results[1] : null);
});
}
};
Loading…
Cancel
Save