jeefo-mysql
Advanced tools
Comparing version 0.0.38 to 0.0.39
20
index.js
@@ -29,20 +29,17 @@ /* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | ||
constructor(table_name, config) { | ||
if (! is.object(config)) { | ||
throw new TypeError("Invalid argument"); | ||
} | ||
if (! is.object(config)) throw new TypeError("Invalid argument"); | ||
this.table_name = table_name; | ||
this.connection = mysql.createConnection(config); | ||
this.is_connected = false; | ||
this.config = () => config; | ||
this.table_name = table_name; | ||
} | ||
connect() { | ||
if (this.connection) return; | ||
if (this.pending) return this.pending; | ||
this.pending = new Promise((resolve, reject) => { | ||
this.connection = mysql.createConnection(this.config()); | ||
this.connection.connect(err => { | ||
this.pending = null; | ||
if (err) return reject(err); | ||
this.is_connected = true; | ||
resolve(); | ||
err ? reject(err) : resolve(); | ||
//const {threadId} = this.connection; | ||
@@ -58,3 +55,2 @@ //console.log(`[Jeefo MySQL] connceted thread id: [${threadId}].`); | ||
return new Promise((resolve, reject) => this.connection.end(err => { | ||
this.is_connected = false; | ||
err ? reject(err) : resolve(); | ||
@@ -68,3 +64,3 @@ //const {threadId} = this.connection; | ||
this.connection.destroy(); | ||
this.is_connected = false; | ||
this.connection = null; | ||
} | ||
@@ -166,3 +162,3 @@ | ||
return new Promise(async (resolve, reject) => { | ||
if (!this.is_connected) await this.connect(); | ||
if (!this.connection) await this.connect(); | ||
@@ -169,0 +165,0 @@ //console.log(`[Jeefo MySQL] exec query: ${query}`); |
{ | ||
"name": "jeefo-mysql", | ||
"version": "0.0.38", | ||
"version": "0.0.39", | ||
"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
16270
444