Comparing version 1.0.21 to 1.0.22
@@ -143,9 +143,9 @@ //Low level connection to PostgreSQL database | ||
// ------------------------------------------------------------------- | ||
query(...args) { // Attempt a DB query. If not yet connected, queue the request and attempt to connect | ||
query(...args) { // Attempt a DB query with callback. | ||
this.log.trace("Query:", this.config.user, args[0].substr(0,256), args[1]) | ||
if (this.client && this.client._connected) { //If connection ready, run the query | ||
this.client.query(...args) | ||
} else { // else save the command for later | ||
return this.client.query(...args) | ||
} else { // else queue the command for later | ||
this.queryQue.push(args) | ||
this.log.trace(" queueing it: ", this.queryQue.length) | ||
this.log.trace(" queueing query: ", this.queryQue.length) | ||
if (!this.connecting) this.connect(() => { //Get this client connected | ||
@@ -155,10 +155,28 @@ let q; while (q = this.queryQue.shift()) this.query(...q) //And process the queue | ||
} | ||
} //query() | ||
} | ||
// ------------------------------------------------------------------- | ||
t(...args) { // Wrap a query in a transaction | ||
t(...args) { // Wrap a callback query in a transaction | ||
args[0] = 'begin; ' + args[0] + '; commit;' | ||
this.query(...args) | ||
} //t() | ||
} | ||
} //class dbClient | ||
// ------------------------------------------------------------------- | ||
async pquery(...args) { // Query DB returning promise/rows | ||
this.log.trace("Exec:", this.config.user, args[0].substr(0,256), args[1]) | ||
if (!this.client) { | ||
await new Promise(resolve => this.connect(resolve)) | ||
} else if (this.client._connected) { | ||
} else { | ||
while (this.connecting) { | ||
await new Promise(resolve => setTimeout(resolve, 250)) | ||
} | ||
} | ||
let result = await this.client.query(...args) | ||
//this.log.trace('F:', Object.keys(result), JSON.stringify(result)) | ||
return result.rows | ||
} | ||
} //class |
//Basic logging if nothing else provided | ||
//Copyright WyattERP.org; See license in root of this package | ||
// ----------------------------------------------------------------------------- | ||
//TODO: | ||
//Usage: export NODE_DEBUG=db //for console debugging | ||
//- | ||
@@ -6,0 +6,0 @@ var logger = require('util').debuglog('db') |
{ | ||
"name": "wyseman", | ||
"version": "1.0.21", | ||
"version": "1.0.22", | ||
"description": "PostgreSQL Schema Manager with Javascript, Ruby, TCL API", | ||
@@ -29,3 +29,3 @@ "main": "lib/index.js", | ||
"wmrestore": "bin/wmrestore", | ||
"wyseman": "bin/wyseman", | ||
"wyseman": "bin/wyseman.js", | ||
"wmmkpkg": "bin/wmmkpkg", | ||
@@ -38,7 +38,8 @@ "wysegi": "bin/wysegi" | ||
"pg-format": "^1.0.4", | ||
"pg-native": "^3.0.0", | ||
"ws": "^7.5.5" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^7.2.0" | ||
"mocha": "^9.1.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
689926
75
1152
5
8
5
+ Addedpg-native@^3.0.0
+ Addedbindings@1.5.0(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedlibpq@1.8.13(transitive)
+ Addednan@2.19.0(transitive)
+ Addedpg-native@3.2.0(transitive)
+ Addedpg-types@1.13.0(transitive)
+ Addedpostgres-array@1.0.3(transitive)