mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 19:21:04 +01:00
fix: returnOriginal deprecation
https://github.com/mongodb/node-mongodb-native/pull/2808
This commit is contained in:
@@ -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