jeefo-mysql
Advanced tools
Comparing version 0.0.40 to 0.0.41
17
index.js
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | ||
* File Name : index.js | ||
* Created at : 2021-10-09 | ||
* Updated at : 2021-12-16 | ||
* Updated at : 2021-12-22 | ||
* Author : jeefo | ||
@@ -49,3 +49,3 @@ * Purpose : | ||
this.connection.on("error", err => { | ||
console.error("MYSQL Error:", err); | ||
console.error("MYSQL Error:", err); | ||
}); | ||
@@ -96,6 +96,6 @@ }); | ||
async insert(data, return_back) { | ||
const fields = this.prepare_set(data); | ||
const {fields, values} = this.prepare_set(data); | ||
const query = `INSERT INTO ${this.table_name} SET ${fields};`; | ||
const res = await this.exec(query); | ||
const res = await this.exec(query, values); | ||
@@ -138,3 +138,4 @@ return ( | ||
prepare_set(data) { | ||
return Object.keys(data).map(key => { | ||
const values = []; | ||
const fields = Object.keys(data).map(key => { | ||
let value = data[key]; | ||
@@ -146,5 +147,7 @@ if (is.object(value) && !(value instanceof Date)) { | ||
} | ||
key = mysql.escapeId(key); | ||
return `${key} = ${value}`; | ||
values.push(value); | ||
return `${mysql.escapeId(key)} = ?`; | ||
}).join(", "); | ||
return {fields, values}; | ||
} | ||
@@ -151,0 +154,0 @@ |
{ | ||
"name": "jeefo-mysql", | ||
"version": "0.0.40", | ||
"version": "0.0.41", | ||
"description": "Very simple MySQL connection instances for each table. I had annoyed enough for MySQL Deadlocks.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16477
449
1