removed helpers.done

v1.18.x
barisusakli 11 years ago
parent e6d0eede4f
commit 94d050fd4f

@ -4,8 +4,9 @@ module.exports = function(db, module) {
var helpers = module.helpers.mongo;
module.setObject = function(key, data, callback) {
callback = callback || helpers.noop;
data._key = key;
db.collection('objects').update({_key:key}, {$set:data}, {upsert:true, w: 1}, helpers.done(callback));
db.collection('objects').update({_key:key}, {$set:data}, {upsert:true, w: 1}, callback);
};
module.setObjectField = function(key, field, value, callback) {
@ -121,10 +122,11 @@ module.exports = function(db, module) {
};
module.deleteObjectField = function(key, field, callback) {
callback = callback || helpers.noop;
var data = {};
field = helpers.fieldToString(field);
data[field] = '';
db.collection('objects').update({_key:key}, {$unset : data}, helpers.done(callback));
db.collection('objects').update({_key:key}, {$unset : data}, callback);
};
module.incrObjectField = function(key, field, callback) {

@ -31,12 +31,6 @@ helpers.valueToString = function(value) {
return value.toString();
};
helpers.done = function(cb) {
return function(err, result) {
if (typeof cb === 'function') {
cb(err, result);
}
};
};
helpers.noop = function() {};
module.exports = helpers;

@ -21,8 +21,9 @@ module.exports = function(db, module) {
};
module.listAppend = function(key, value, callback) {
callback = callback || helpers.noop;
value = helpers.valueToString(value);
db.collection('objects').update({ _key: key }, { $push: { array: value } }, {upsert:true, w:1}, helpers.done(callback));
db.collection('objects').update({ _key: key }, { $push: { array: value } }, {upsert:true, w:1}, callback);
};
module.listRemoveLast = function(key, callback) {
@ -50,9 +51,10 @@ module.exports = function(db, module) {
};
module.listRemoveAll = function(key, value, callback) {
callback = callback || helpers.noop;
value = helpers.valueToString(value);
db.collection('objects').update({_key: key }, { $pull: { array: value } }, helpers.done(callback));
db.collection('objects').update({_key: key }, { $pull: { array: value } }, callback);
};
module.getListRange = function(key, start, stop, callback) {

@ -40,11 +40,13 @@ module.exports = function(db, module) {
};
module.searchRemove = function(key, id, callback) {
db.collection('search').remove({id:id, key:key}, helpers.done(callback));
callback = callback || helpers.noop;
db.collection('search').remove({id:id, key:key}, callback);
};
module.flushdb = function(callback) {
db.dropDatabase(helpers.done(callback));
callback = callback || helpers.noop;
db.dropDatabase(callback);
};
module.info = function(callback) {
@ -68,7 +70,8 @@ module.exports = function(db, module) {
};
module.delete = function(key, callback) {
db.collection('objects').remove({_key:key}, helpers.done(callback));
callback = callback || helpers.noop;
db.collection('objects').remove({_key:key}, callback);
};
module.get = function(key, callback) {
@ -81,11 +84,13 @@ module.exports = function(db, module) {
};
module.increment = function(key, callback) {
db.collection('objects').update({_key: key}, { $inc: { value: 1 } }, helpers.done(callback));
callback = callback || helpers.noop;
db.collection('objects').update({_key: key}, { $inc: { value: 1 } }, callback);
};
module.rename = function(oldKey, newKey, callback) {
db.collection('objects').update({_key: oldKey}, {$set:{_key: newKey}}, helpers.done(callback));
callback = callback || helpers.noop;
db.collection('objects').update({_key: oldKey}, {$set:{_key: newKey}}, callback);
};
module.expire = function(key, seconds, callback) {

@ -4,6 +4,7 @@ module.exports = function(db, module) {
var helpers = module.helpers.mongo;
module.setAdd = function(key, value, callback) {
callback = callback || helpers.noop;
if(!Array.isArray(value)) {
value = [value];
}
@ -23,10 +24,11 @@ module.exports = function(db, module) {
}, {
upsert: true,
w: 1
}, helpers.done(callback));
}, callback);
};
module.setRemove = function(key, value, callback) {
callback = callback || helpers.noop;
if(!Array.isArray(value)) {
value = [value];
}
@ -35,7 +37,7 @@ module.exports = function(db, module) {
array[index] = helpers.valueToString(element);
});
db.collection('objects').update({_key: key}, {$pullAll: {members: value}}, helpers.done(callback));
db.collection('objects').update({_key: key}, {$pullAll: {members: value}}, callback);
};
module.isSetMember = function(key, value, callback) {

@ -6,25 +6,28 @@ module.exports = function(db, module) {
var helpers = module.helpers.mongo;
module.sortedSetAdd = function(key, score, value, callback) {
callback = callback || helpers.noop;
value = helpers.valueToString(value);
var data = {
score: parseInt(score, 10),
value: value
};
db.collection('objects').update({_key: key, value: value}, {$set: data}, {upsert:true, w: 1}, helpers.done(callback));
db.collection('objects').update({_key: key, value: value}, {$set: data}, {upsert:true, w: 1}, callback);
};
module.sortedSetRemove = function(key, value, callback) {
callback = callback || helpers.noop;
value = helpers.valueToString(value);
db.collection('objects').remove({_key: key, value: value}, helpers.done(callback));
db.collection('objects').remove({_key: key, value: value}, callback);
};
module.sortedSetsRemove = function(keys, value, callback) {
callback = callback || helpers.noop;
value = helpers.valueToString(value);
db.collection('objects').remove({_key: {$in: keys}, value: value}, helpers.done(callback));
db.collection('objects').remove({_key: {$in: keys}, value: value}, callback);
};
function getSortedSetRange(key, start, stop, sort, withScores, callback) {

Loading…
Cancel
Save