mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
fix rename and increment
This commit is contained in:
@@ -117,12 +117,16 @@ module.exports = function(db, module) {
|
||||
if (!key) {
|
||||
return callback();
|
||||
}
|
||||
db.collection('objects').update({_key: key}, { $inc: { value: 1 } }, callback);
|
||||
db.collection('objects').findAndModify({_key: key}, {}, {$inc: {value: 1}}, {new: true, upsert: true}, function(err, result) {
|
||||
callback(err, result ? result.value : null);
|
||||
});
|
||||
};
|
||||
|
||||
module.rename = function(oldKey, newKey, callback) {
|
||||
callback = callback || helpers.noop;
|
||||
db.collection('objects').update({_key: oldKey}, {$set:{_key: newKey}}, {multi: true}, callback);
|
||||
db.collection('objects').update({_key: oldKey}, {$set:{_key: newKey}}, {multi: true}, function(err, res) {
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
|
||||
module.expire = function(key, seconds, callback) {
|
||||
|
||||
Reference in New Issue
Block a user