1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Fix MongoDB connection close on node close (#737)

closes #738
This commit is contained in:
Adrien GILLON 2021-01-22 14:48:01 +01:00 committed by GitHub
parent ea92f293e2
commit 4cfc7b39be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,7 +83,7 @@ module.exports = function(RED) {
} }
else { else {
node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")}); node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")});
node.clientDb = client.db(); node.client = client;
var db = client.db(); var db = client.db();
//console.log( db); //console.log( db);
noerror = true; noerror = true;
@ -185,7 +185,7 @@ module.exports = function(RED) {
node.on("close", function() { node.on("close", function() {
node.status({}); node.status({});
if (node.tout) { clearTimeout(node.tout); } if (node.tout) { clearTimeout(node.tout); }
if (node.clientDb) { node.clientDb.close(); } if (node.client) { node.client.close(); }
}); });
} }
RED.nodes.registerType("mongodb out",MongoOutNode); RED.nodes.registerType("mongodb out",MongoOutNode);
@ -212,7 +212,7 @@ module.exports = function(RED) {
} }
else { else {
node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")}); node.status({fill:"green",shape:"dot",text:RED._("mongodb.status.connected")});
node.clientDb = client.db(); node.client = client;
var db = client.db(); var db = client.db();
noerror = true; noerror = true;
var coll; var coll;
@ -303,7 +303,7 @@ module.exports = function(RED) {
node.on("close", function() { node.on("close", function() {
node.status({}); node.status({});
if (node.tout) { clearTimeout(node.tout); } if (node.tout) { clearTimeout(node.tout); }
if (node.clientDb) { node.clientDb.close(); } if (node.client) { node.client.close(); }
}); });
} }
RED.nodes.registerType("mongodb in",MongoInNode); RED.nodes.registerType("mongodb in",MongoInNode);