From cd10b3dc3edc06edc10a92705f36cd0affff38f8 Mon Sep 17 00:00:00 2001 From: Andrew Molchanov Date: Thu, 3 Dec 2020 21:05:09 +0300 Subject: [PATCH] fixed deprecation warnings --- lib/document_stores/mongodb.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/document_stores/mongodb.js b/lib/document_stores/mongodb.js index e700212..250dbe3 100644 --- a/lib/document_stores/mongodb.js +++ b/lib/document_stores/mongodb.js @@ -15,16 +15,18 @@ MongoDocumentStore.prototype.set = function (key, data, callback, skipExpire) { if (err) return callback(false); - db.collection('entries').update({ + db.collection('entries').updateOne({ 'entry_id': key, $or: [ { expiration: -1 }, { expiration: { $gt: now } } ] }, { - 'entry_id': key, - 'value': data, - 'expiration': that.expire && !skipExpire ? that.expire + now : -1 + $set: { + 'entry_id': key, + 'value': data, + 'expiration': that.expire && !skipExpire ? that.expire + now : -1 + } }, { upsert: true }, function (err, existing) { @@ -61,7 +63,7 @@ MongoDocumentStore.prototype.get = function (key, callback, skipExpire) { callback(entry === null ? false : entry.value); if (entry !== null && entry.expiration !== -1 && that.expire && !skipExpire) { - db.collection('entries').update({ + db.collection('entries').updateOne({ 'entry_id': key }, { $set: { @@ -74,7 +76,7 @@ MongoDocumentStore.prototype.get = function (key, callback, skipExpire) { }; MongoDocumentStore.prototype.safeConnect = function (callback) { - MongoClient.connect(this.connectionUrl, function (err, client) { + MongoClient.connect(this.connectionUrl, { useUnifiedTopology: true }, function (err, client) { if (err) { winston.error('error connecting to mongodb', { error: err }); callback(err);