fix: returnOriginal deprecation

https://github.com/mongodb/node-mongodb-native/pull/2808
This commit is contained in:
Barış Soner Uşaklı
2021-05-28 11:12:21 -04:00
parent e6c3840a4d
commit 3fb7444580
3 changed files with 24 additions and 3 deletions

View File

@@ -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;
};