mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-08 16:42:48 +01:00
cleaned up a bit
This commit is contained in:
@@ -27,36 +27,26 @@ module.exports = function(db, module) {
|
||||
};
|
||||
|
||||
module.listRemoveLast = function(key, callback) {
|
||||
callback = callback || function() {};
|
||||
module.getListRange(key, -1, 0, function(err, value) {
|
||||
if(err) {
|
||||
if(typeof callback === 'function') {
|
||||
return callback(err);
|
||||
}
|
||||
return;
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
db.collection('objects').update({_key: key }, { $pop: { array: 1 } }, function(err, result) {
|
||||
if(typeof callback === 'function') {
|
||||
callback(err, (value && value.length) ? value[0] : null);
|
||||
}
|
||||
callback(err, (value && value.length) ? value[0] : null);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.listTrim = function(key, start, stop, callback) {
|
||||
callback = callback || function() {};
|
||||
module.getListRange(key, start, stop, function(err, value) {
|
||||
if(err) {
|
||||
if(typeof callback === 'function') {
|
||||
return callback(err);
|
||||
}
|
||||
return;
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
db.collection('objects').update({_key: key}, {$set: {array: value }}, function(err, result) {
|
||||
if(typeof callback === 'function') {
|
||||
callback(err, (value && value.length) ? value[0] : null);
|
||||
}
|
||||
});
|
||||
db.collection('objects').update({_key: key}, {$set: {array: value}}, callback);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user