postgresql-client
Advanced tools
Comparing version 1.9.0 to 1.9.1
@@ -11,2 +11,4 @@ "use strict"; | ||
const common_1 = require("./common"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const debug = debug_1.default('pgc:cursor'); | ||
class Cursor extends SafeEventEmitter_1.SafeEventEmitter { | ||
@@ -23,2 +25,3 @@ constructor(statement, portal, fields, parsers, queryOptions) { | ||
this.fields = fields; | ||
debug('[%s] constructor', this._portal.name); | ||
} | ||
@@ -54,2 +57,3 @@ get rowType() { | ||
return; | ||
debug('[%s] close', this._portal.name); | ||
await this._portal.close(); | ||
@@ -63,2 +67,3 @@ await this._statement.close(); | ||
await this._taskQueue.enqueue(async () => { | ||
debug('[%s] fetching rows', this._portal.name); | ||
const queryOptions = this._queryOptions; | ||
@@ -79,2 +84,3 @@ const r = await portal.execute(queryOptions.fetchCount || 100); | ||
this._rows.push(...r.rows); | ||
debug('[%s] %d rows fetched', this._portal.name, r.rows.length); | ||
this.emit('fetch', r.rows); | ||
@@ -81,0 +87,0 @@ } |
@@ -18,2 +18,4 @@ "use strict"; | ||
const putil_varhelpers_1 = require("putil-varhelpers"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const debug = debug_1.default('pgc:intlcon'); | ||
class IntlConnection extends SafeEventEmitter_1.SafeEventEmitter { | ||
@@ -55,2 +57,3 @@ constructor(config) { | ||
return; | ||
debug('connecting'); | ||
await new Promise((resolve, reject) => { | ||
@@ -61,3 +64,2 @@ const handleConnectError = (err) => reject(err); | ||
resolve(); | ||
this.emit('ready'); | ||
}); | ||
@@ -74,2 +76,4 @@ this.socket.once('error', handleConnectError); | ||
await this.execute(startupCommand, { autoCommit: true }); | ||
debug('[%s] ready', this.processID); | ||
this.emit('ready'); | ||
} | ||
@@ -79,2 +83,3 @@ async close() { | ||
return; | ||
debug('[%s] closing', this.processID); | ||
this.statementQueue.clear(); | ||
@@ -87,2 +92,3 @@ return new Promise(resolve => { | ||
this.socket.close(); | ||
debug('[%s] closed', this.processID); | ||
this.emit('close'); | ||
@@ -122,5 +128,8 @@ }); | ||
this._refCount++; | ||
debug('[%s] ref %d', this.processID, this._refCount); | ||
} | ||
unref() { | ||
return !--this._refCount; | ||
this._refCount--; | ||
debug('[%s] unref %d', this.processID, this._refCount); | ||
return !this._refCount; | ||
} | ||
@@ -136,2 +145,3 @@ assertConnected() { | ||
try { | ||
debug('[%s] execute | %s', this.processID, sql.substring(0, 30)); | ||
const startTime = Date.now(); | ||
@@ -220,2 +230,3 @@ const result = { | ||
return; | ||
debug('[%s] error | %s', this.processID, err.message); | ||
this.emit('error', err); | ||
@@ -222,0 +233,0 @@ } |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -12,2 +15,4 @@ exports.Pool = void 0; | ||
const common_1 = require("./common"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const debug = debug_1.default('pgc:connection'); | ||
class Pool extends SafeEventEmitter_1.SafeEventEmitter { | ||
@@ -34,6 +39,11 @@ constructor(config) { | ||
intlCon.on('close', () => this._pool.destroy(intlCon, () => 0)); | ||
debug('created connection %s', intlCon.processID); | ||
return intlCon; | ||
}, | ||
destroy: intlCon => intlCon.close(), | ||
destroy: intlCon => { | ||
debug('destroy connection %s', intlCon.processID); | ||
return intlCon.close(); | ||
}, | ||
reset: async (intlCon) => { | ||
debug('reset connection %s', intlCon.processID); | ||
try { | ||
@@ -49,2 +59,3 @@ if (intlCon.state === definitions_1.ConnectionState.READY) | ||
validate: async (intlCon) => { | ||
debug('validate connection %s', intlCon.processID); | ||
if (intlCon.state !== definitions_1.ConnectionState.READY) | ||
@@ -85,2 +96,3 @@ throw new Error('Connection is not active'); | ||
const intlCon = await this._pool.acquire(); | ||
debug('acquired connection %s', intlCon.processID); | ||
return new Connection_1.Connection(this, intlCon); | ||
@@ -120,2 +132,3 @@ } | ||
async prepare(sql, options) { | ||
debug('prepare | %s', sql); | ||
const connection = await this.acquire(); | ||
@@ -122,0 +135,0 @@ const statement = await connection.prepare(sql, options); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -8,2 +11,4 @@ exports.Portal = void 0; | ||
const common_1 = require("./common"); | ||
const debug_1 = __importDefault(require("debug")); | ||
const debug = debug_1.default('pgc:portal'); | ||
class Portal { | ||
@@ -22,2 +27,3 @@ constructor(statement, name) { | ||
async bind(params, queryOptions) { | ||
debug('[%s] bind', this.name); | ||
const intoCon = common_1.getIntlConnection(this.connection); | ||
@@ -55,2 +61,3 @@ intoCon.ref(); | ||
async retrieveFields() { | ||
debug('[%s] retrieveFields', this.name); | ||
const intoCon = common_1.getIntlConnection(this.connection); | ||
@@ -82,2 +89,3 @@ intoCon.ref(); | ||
async execute(fetchCount) { | ||
debug('[%s] execute', this.name); | ||
const intoCon = common_1.getIntlConnection(this.connection); | ||
@@ -127,2 +135,3 @@ intoCon.ref(); | ||
async close() { | ||
debug('[%s] close', this.name); | ||
const intoCon = common_1.getIntlConnection(this.connection); | ||
@@ -129,0 +138,0 @@ intoCon.ref(); |
{ | ||
"name": "postgresql-client", | ||
"description": "Professional PostgreSQL client for JavaScript and TypeScript", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"author": "Panates", | ||
@@ -27,2 +27,3 @@ "contributors": [ | ||
"dependencies": { | ||
"debug": "^4.3.1", | ||
"doublylinked": "^2.4.3", | ||
@@ -36,9 +37,10 @@ "lightning-pool": "^3.0.1", | ||
"devDependencies": { | ||
"@types/debug": "^4.1.5", | ||
"@types/mocha": "^8.0.4", | ||
"@types/node": "^14.14.8", | ||
"@typescript-eslint/eslint-plugin": "^4.8.1", | ||
"@typescript-eslint/parser": "^4.8.1", | ||
"@types/node": "^14.14.9", | ||
"@typescript-eslint/eslint-plugin": "^4.8.2", | ||
"@typescript-eslint/parser": "^4.8.2", | ||
"babel-eslint": "^10.1.0", | ||
"dotenv": "^8.2.0", | ||
"eslint": "^7.13.0", | ||
"eslint": "^7.14.0", | ||
"eslint-config-google": "^0.14.0", | ||
@@ -53,3 +55,3 @@ "mocha": "^8.2.1", | ||
"tsconfig-paths": "^3.9.0", | ||
"typescript": "^4.0.5" | ||
"typescript": "^4.1.2" | ||
}, | ||
@@ -56,0 +58,0 @@ "main": "dist/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
185245
4782
7
18
+ Addeddebug@^4.3.1
+ Addeddebug@4.4.0(transitive)
+ Addedms@2.1.3(transitive)