From 4cfc7b39be1215ddb0830183eae3cc0244b2151a Mon Sep 17 00:00:00 2001 From: Adrien GILLON Date: Fri, 22 Jan 2021 14:48:01 +0100 Subject: [PATCH] Fix MongoDB connection close on node close (#737) closes #738 --- storage/mongodb/66-mongodb.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/storage/mongodb/66-mongodb.js b/storage/mongodb/66-mongodb.js index 8a751640..4b635193 100644 --- a/storage/mongodb/66-mongodb.js +++ b/storage/mongodb/66-mongodb.js @@ -83,7 +83,7 @@ module.exports = function(RED) { } else { node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")}); - node.clientDb = client.db(); + node.client = client; var db = client.db(); //console.log( db); noerror = true; @@ -185,7 +185,7 @@ module.exports = function(RED) { node.on("close", function() { node.status({}); if (node.tout) { clearTimeout(node.tout); } - if (node.clientDb) { node.clientDb.close(); } + if (node.client) { node.client.close(); } }); } RED.nodes.registerType("mongodb out",MongoOutNode); @@ -212,7 +212,7 @@ module.exports = function(RED) { } else { node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")}); - node.clientDb = client.db(); + node.client = client; var db = client.db(); noerror = true; var coll; @@ -303,7 +303,7 @@ module.exports = function(RED) { node.on("close", function() { node.status({}); if (node.tout) { clearTimeout(node.tout); } - if (node.clientDb) { node.clientDb.close(); } + if (node.client) { node.client.close(); } }); } RED.nodes.registerType("mongodb in",MongoInNode);