Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-node-mysql

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-node-mysql - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

73

68-mysql.js

@@ -21,42 +21,3 @@ /**

var mysqldb = require('mysql');
var querystring = require('querystring');
RED.httpAdmin.get('/MySQLdatabase/:id',function(req,res) {
var credentials = RED.nodes.getCredentials(req.params.id);
if (credentials) {
res.send(JSON.stringify({user:credentials.user,hasPassword:(credentials.password&&credentials.password!=="")}));
} else {
res.send(JSON.stringify({}));
}
});
RED.httpAdmin.delete('/MySQLdatabase/:id',function(req,res) {
RED.nodes.deleteCredentials(req.params.id);
res.send(200);
});
RED.httpAdmin.post('/MySQLdatabase/:id',function(req,res) {
var body = "";
req.on('data', function(chunk) {
body+=chunk;
});
req.on('end', function(){
var newCreds = querystring.parse(body);
var credentials = RED.nodes.getCredentials(req.params.id)||{};
if (newCreds.user == null || newCreds.user === "") {
delete credentials.user;
} else {
credentials.user = newCreds.user;
}
if (newCreds.password === "") {
delete credentials.password;
} else {
credentials.password = newCreds.password||credentials.password;
}
RED.nodes.addCredentials(req.params.id,credentials);
res.send(200);
});
});
function MySQLNode(n) {

@@ -71,17 +32,2 @@ RED.nodes.createNode(this,n);

var credentials = {};
if (n.user) {
credentials.user = n.user;
credentials.password = n.pass;
RED.nodes.addCredentials(n.id,credentials);
this.user = n.user;
this.password = n.pass;
} else {
credentials = RED.nodes.getCredentials(n.id);
if (credentials) {
this.user = credentials.user;
this.password = credentials.password;
}
}
this.dbname = n.db;

@@ -95,4 +41,4 @@ var node = this;

port : node.port,
user : node.user,
password : node.password,
user : node.credentials.user,
password : node.credentials.password,
database : node.dbname,

@@ -130,3 +76,3 @@ timezone : node.tz,

this.on('close', function () {
this.on('close', function (done) {
if (this.tick) { clearTimeout(this.tick); }

@@ -136,7 +82,15 @@ if (this.connection) {

if (err) { node.error(err); }
done();
});
} else {
done();
}
});
}
RED.nodes.registerType("MySQLdatabase",MySQLNode);
RED.nodes.registerType("MySQLdatabase",MySQLNode, {
credentials: {
user: {type: "text"},
password: {type: "password"}
}
});

@@ -155,3 +109,4 @@

//console.log("query:",msg.topic);
node.mydbConfig.connection.query(msg.topic, function(err, rows) {
var bind = Array.isArray(msg.payload) ? msg.payload : [];
node.mydbConfig.connection.query(msg.topic, bind, function(err, rows) {
if (err) { node.warn(err); }

@@ -158,0 +113,0 @@ else {

4

package.json
{
"name" : "node-red-node-mysql",
"version" : "0.0.4",
"version" : "0.0.5",
"description" : "A Node-RED node to read and write to a MySQL database",
"dependencies" : {
"mysql" : "2.3.*"
"mysql" : "2.5.*"
},

@@ -8,0 +8,0 @@ "repository" : {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc