Skip to content

Node.js based forum software built for the modern web

fix: returnOriginal deprecation

Barış Soner Uşaklı3fb744458041
diff --git a/src/database/mongo/hash.js b/src/database/mongo/hash.js
index ec8a0b9c03..0829bbf8af 100644
--- a/src/database/mongo/hash.js
+++ b/src/database/mongo/hash.js
@@ -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;
};
diff --git a/src/database/mongo/main.js b/src/database/mongo/main.js
index 1e4f7e51df..e7b961a30c 100644
--- a/src/database/mongo/main.js
+++ b/src/database/mongo/main.js
@@ -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;
};
diff --git a/src/database/mongo/sorted.js b/src/database/mongo/sorted.js
index 87664c71ed..7b59828e49 100644
--- a/src/database/mongo/sorted.js
+++ b/src/database/mongo/sorted.js
@@ -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