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.22 to 0.1.0

18

68-mysql.js

@@ -126,3 +126,19 @@

if (typeof msg.topic === 'string') {
var bind = Array.isArray(msg.payload) ? msg.payload : [];
//console.log("query:",msg.topic);
var bind = [];
if (Array.isArray(msg.payload)) { bind = msg.payload; }
else if (typeof msg.payload === 'object' && msg.payload !== null) {
bind=msg.payload;
node.mydbConfig.connection.config.queryFormat = function (query, values) {
if (!values){
return query;
}
return query.replace(/\:(\w+)/g, function (txt, key) {
if (values.hasOwnProperty(key)) {
return this.escape(values[key]);
}
return txt;
}.bind(this));
};
}
node.mydbConfig.connection.query(msg.topic, bind, function(err, rows) {

@@ -129,0 +145,0 @@ if (err) {

2

package.json
{
"name": "node-red-node-mysql",
"version": "0.0.22",
"version": "0.1.0",
"description": "A Node-RED node to read and write to a MySQL database",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -30,1 +30,24 @@ node-red-node-mysql

<pre>mysqlReconnectTime: 30000,</pre></p>
Preparing Queries
-----
```javascript
msg.payload=[24, 'example-user'];
msg.topic="INSERT INTO users (`userid`, `username`) VALUES (?, ?);"
return msg;
```
with named parameters:
```javascript
msg.payload={}
msg.payload.userToChange=42;
msg.payload.newUsername="example-user";
msg.topic="INSERT INTO users (`userid`, `username`) VALUES (:userToChange, :newUsername) ON DUPLICATE KEY UPDATE `username`=:newUsername;"
return msg;
```
Documentation
-----
<a href="https://www.npmjs.com/package/mysql" target="_new">Documentation</a> of the used Node.js package
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