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

Fixup mysql node done calls

This commit is contained in:
Dave Conway-Jones 2021-04-08 17:07:23 +01:00
parent 915089f2fb
commit 2c5cc5f70c
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 6 additions and 4 deletions

View File

@ -124,6 +124,7 @@ module.exports = function(RED) {
}); });
node.on("input", function(msg, send, done) { node.on("input", function(msg, send, done) {
send = send || function() { node.send.apply(node,arguments) };
if (node.mydbConfig.connected) { if (node.mydbConfig.connected) {
if (typeof msg.topic === 'string') { if (typeof msg.topic === 'string') {
//console.log("query:",msg.topic); //console.log("query:",msg.topic);
@ -157,23 +158,24 @@ module.exports = function(RED) {
msg.payload = rows.map(v => Object.assign({}, v)); msg.payload = rows.map(v => Object.assign({}, v));
} }
else { msg.payload = rows; } else { msg.payload = rows; }
node.send(msg); send(msg);
status = {fill:"green",shape:"dot",text:"OK"}; status = {fill:"green",shape:"dot",text:"OK"};
node.status(status); node.status(status);
done();
} }
done();
// if (node.mydbConfig.pool._freeConnections.indexOf(node.mydbConfig.connection) === -1) { // if (node.mydbConfig.pool._freeConnections.indexOf(node.mydbConfig.connection) === -1) {
// node.mydbConfig.connection.release(); // node.mydbConfig.connection.release();
// } // }
}); });
} }
else { else {
if (typeof msg.topic !== 'string') { node.error("msg.topic : the query is not defined as a string"); } if (typeof msg.topic !== 'string') { node.error("msg.topic : the query is not defined as a string"); done(); }
} }
} }
else { else {
node.error("Database not connected",msg); node.error("Database not connected",msg);
status = {fill:"red",shape:"ring",text:"not yet connected"}; status = {fill:"red",shape:"ring",text:"not yet connected"};
done();
} }
if (!busy) { if (!busy) {
busy = true; busy = true;

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-node-mysql", "name": "node-red-node-mysql",
"version": "0.1.6", "version": "0.1.7",
"description": "A Node-RED node to read and write to a MySQL database", "description": "A Node-RED node to read and write to a MySQL database",
"dependencies": { "dependencies": {
"mysql": "^2.18.1" "mysql": "^2.18.1"