Socket
Socket
Sign inDemoInstall

jeefo-mysql

Package Overview
Dependencies
13
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.3

48

index.js

@@ -19,2 +19,3 @@ /* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.

let path = require("path"),
async = require("async"),
config_path = path.resolve(process.cwd(), "config"),

@@ -24,8 +25,47 @@ config = require(config_path).database,

let mysql_connection_instances = {};
let mysql_connections_container = {};
module.exports = table => {
return mysql_connection_instances[table] || (
mysql_connection_instances[table] = mysql_connection(config)
let filter = (conn, database, table, data, callback) => {
let column_names = Object.keys(data);
async.waterfall(
[
cb => {
let query = `
SELECT \`COLUMN_NAME\` FROM \`INFORMATION_SCHEMA\`.\`COLUMNS\`
WHERE
\`TABLE_SCHEMA\` = ? AND
\`TABLE_NAME\` = ? AND
\`COLUMN_NAME\` IN(?)
`;
conn(query, [database, table, column_names], cb);
},
(columns, f, cb) => {
columns = columns.map(c => c.COLUMN_NAME);
let filtered_data = columns.reduce((payload, key) => {
payload[key] = data[key];
return payload;
}, {});
cb(null, filtered_data);
}
],
callback
);
};
module.exports = table => {
let connection = mysql_connections_container[table];
if (! connection) {
connection = mysql_connections_container[table] = mysql_connection(config);
connection.filter = (data, callback) => {
filter(connection, config.database, table, data, callback);
};
}
return connection;
};

9

package.json
{
"name": "jeefo-mysql",
"version": "0.0.2",
"description": "MySQL connection instances for each table. I had annoyed enough for MySQL Deadlocks.",
"version": "0.0.3",
"description": "Very simple MySQL connection instances for each table. I had annoyed enough for MySQL Deadlocks.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"repository": {
"type": "git",
"url": "git://github.com:je3f0o/node-jeefo-mysql.git"
},

@@ -9,0 +10,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc