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

View File

@ -1,6 +1,6 @@
{
"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",
"dependencies": {
"mysql": "^2.18.1"