mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 10:46:14 +01:00
fix: returnOriginal deprecation
https://github.com/mongodb/node-mongodb-native/pull/2808
This commit is contained in:
@@ -222,7 +222,15 @@ module.exports = function (module) {
|
||||
return result.map(data => data && data[field]);
|
||||
}
|
||||
|
||||
const result = await module.client.collection('objects').findOneAndUpdate({ _key: key }, { $inc: increment }, { returnOriginal: false, upsert: true });
|
||||
const result = await module.client.collection('objects').findOneAndUpdate({
|
||||
_key: key,
|
||||
}, {
|
||||
$inc: increment,
|
||||
}, {
|
||||
returnDocument: 'after',
|
||||
upsert: true,
|
||||
});
|
||||
|
||||
cache.del(key);
|
||||
return result && result.value ? result.value[field] : null;
|
||||
};
|
||||
|
||||
@@ -90,7 +90,12 @@ module.exports = function (module) {
|
||||
}
|
||||
const result = await module.client.collection('objects').findOneAndUpdate({
|
||||
_key: key,
|
||||
}, { $inc: { data: 1 } }, { returnOriginal: false, upsert: true });
|
||||
}, {
|
||||
$inc: { data: 1 },
|
||||
}, {
|
||||
returnDocument: 'after',
|
||||
upsert: true,
|
||||
});
|
||||
return result && result.value ? result.value.data : null;
|
||||
};
|
||||
|
||||
|
||||
@@ -400,7 +400,15 @@ module.exports = function (module) {
|
||||
data.score = parseFloat(increment);
|
||||
|
||||
try {
|
||||
const result = await module.client.collection('objects').findOneAndUpdate({ _key: key, value: value }, { $inc: data }, { returnOriginal: false, upsert: true });
|
||||
const result = await module.client.collection('objects').findOneAndUpdate({
|
||||
_key: key,
|
||||
value: value,
|
||||
}, {
|
||||
$inc: data,
|
||||
}, {
|
||||
returnDocument: 'after',
|
||||
upsert: true,
|
||||
});
|
||||
return result && result.value ? result.value.score : null;
|
||||
} catch (err) {
|
||||
// if there is duplicate key error retry the upsert
|
||||
|
||||
Reference in New Issue
Block a user