pg-promise 11.13.0 → 11.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -8
- package/lib/events.js +7 -0
- package/lib/index.js +6 -5
- package/lib/main.js +1 -1
- package/lib/query.js +3 -2
- package/package.json +13 -13
- package/typescript/README.md +1 -1
- package/typescript/pg-promise.d.ts +39 -48
- package/typescript/pg-subset.d.ts +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@ pg-promise
|
|
|
2
2
|
==========
|
|
3
3
|
|
|
4
4
|
[](https://github.com/vitaly-t/pg-promise/actions/workflows/ci.yml)
|
|
5
|
-
[](https://nodejs.org)
|
|
6
6
|
[](https://www.postgresql.org)
|
|
7
7
|
|
|
8
8
|
---
|
|
@@ -12,7 +12,6 @@ PostgreSQL interface for Node.js
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
14
|
* [About](#about)
|
|
15
|
-
* [Support & Sponsorship](#support--sponsorship)
|
|
16
15
|
* [Documentation](#documentation)
|
|
17
16
|
* [Contributing](#contributing)
|
|
18
17
|
* [Usage]
|
|
@@ -59,12 +58,6 @@ At its inception in 2015, this library was only adding promises to the base driv
|
|
|
59
58
|
And while the original name was kept, the library's functionality was vastly extended, with promises now being
|
|
60
59
|
only its tiny part.
|
|
61
60
|
|
|
62
|
-
# Support & Sponsorship
|
|
63
|
-
|
|
64
|
-
I do free support here and on [StackOverflow](https://stackoverflow.com/questions/tagged/pg-promise).
|
|
65
|
-
|
|
66
|
-
And if you want to help this project, I can accept Bitcoin: `1yki7MXMkuDw8qqe5icVdh1GJZSQSzKZp`
|
|
67
|
-
|
|
68
61
|
# Documentation
|
|
69
62
|
|
|
70
63
|
Chapter [Usage] below explains the basics you need to know, while the [Official Documentation]
|
package/lib/events.js
CHANGED
|
@@ -527,6 +527,13 @@ module.exports = {Events};
|
|
|
527
527
|
* - there were no parameters passed into the query method;
|
|
528
528
|
* - property `query` of this object already contains all the formatting values in it, so logging only the query is sufficient.
|
|
529
529
|
*
|
|
530
|
+
* @property {*} values - The original parameter values passed into the query method.
|
|
531
|
+
* It is set for all events.
|
|
532
|
+
*
|
|
533
|
+
* @property {string|undefined} queryFilePath
|
|
534
|
+
* File path of a {@link QueryFile}, if the query comes from an external SQL file.
|
|
535
|
+
* This is set only when the query originates from a {@link QueryFile} and only for events {@link event:query query} and {@link event:error error}.
|
|
536
|
+
*
|
|
530
537
|
* @property {TaskContext} ctx
|
|
531
538
|
* _Task/Transaction Context_ object.
|
|
532
539
|
*
|
package/lib/index.js
CHANGED
|
@@ -12,17 +12,18 @@ var v = process.versions.node.split('.'),
|
|
|
12
12
|
highVer = +v[0];
|
|
13
13
|
|
|
14
14
|
// istanbul ignore next
|
|
15
|
-
if (highVer <
|
|
15
|
+
if (highVer < 16) {
|
|
16
16
|
|
|
17
|
-
// From pg-promise v11.
|
|
17
|
+
// From pg-promise v11.15.0, the oldest supported Node.js is v16.0.0
|
|
18
18
|
|
|
19
|
-
// Node.js
|
|
20
|
-
// Node.js
|
|
19
|
+
// Node.js v14.x was supported up to pg-promise v11.14.0
|
|
20
|
+
// Node.js v12.x was supported up to pg-promise v10.15.4
|
|
21
|
+
// Node.js v8.x was supported up to pg-promise v10.14.2
|
|
21
22
|
// Node.js v7.6.0 was supported up to pg-promise v10.3.5
|
|
22
23
|
// Node.js v4.5.0 was supported up to pg-promise v8.7.5
|
|
23
24
|
// Node.js v0.10 was supported up to pg-promise v5.5.8
|
|
24
25
|
|
|
25
|
-
throw new Error('Minimum Node.js version supported by pg-promise is
|
|
26
|
+
throw new Error('Minimum Node.js version supported by pg-promise is 16.0.0');
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
module.exports = require('./main');
|
package/lib/main.js
CHANGED
package/lib/query.js
CHANGED
|
@@ -42,7 +42,7 @@ function $query(ctx, query, values, qrm, config) {
|
|
|
42
42
|
const opt = ctx.options,
|
|
43
43
|
capSQL = opt.capSQL;
|
|
44
44
|
|
|
45
|
-
let error, entityType,
|
|
45
|
+
let error, entityType, queryFilePath,
|
|
46
46
|
pgFormatting = opt.pgFormatting,
|
|
47
47
|
params = pgFormatting ? values : undefined;
|
|
48
48
|
|
|
@@ -67,6 +67,7 @@ function $query(ctx, query, values, qrm, config) {
|
|
|
67
67
|
error = query.error;
|
|
68
68
|
query = query.file;
|
|
69
69
|
} else {
|
|
70
|
+
queryFilePath = query.file;
|
|
70
71
|
query = query[QueryFile.$query];
|
|
71
72
|
}
|
|
72
73
|
} else {
|
|
@@ -240,7 +241,7 @@ function $query(ctx, query, values, qrm, config) {
|
|
|
240
241
|
error = new Error(npm.text.looseQuery);
|
|
241
242
|
}
|
|
242
243
|
return {
|
|
243
|
-
client, query, params,
|
|
244
|
+
client, query, params, queryFilePath, values,
|
|
244
245
|
dc: ctx.dc,
|
|
245
246
|
ctx: ctx.ctx
|
|
246
247
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pg-promise",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.15.0",
|
|
4
4
|
"description": "PostgreSQL interface for Node.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "typescript/pg-promise.d.ts",
|
|
@@ -38,30 +38,30 @@
|
|
|
38
38
|
},
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
41
|
+
"node": ">=16.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"assert-options": "0.8.
|
|
45
|
-
"pg": "8.
|
|
46
|
-
"pg-minify": "1.
|
|
47
|
-
"spex": "3.4.
|
|
44
|
+
"assert-options": "0.8.3",
|
|
45
|
+
"pg": "8.16.3",
|
|
46
|
+
"pg-minify": "1.8.0",
|
|
47
|
+
"spex": "3.4.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"pg-query-stream": "4.
|
|
50
|
+
"pg-query-stream": "4.10.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@eslint/js": "9.
|
|
54
|
-
"@types/node": "
|
|
53
|
+
"@eslint/js": "9.30.1",
|
|
54
|
+
"@types/node": "24.0.10",
|
|
55
55
|
"bluebird": "3.7.2",
|
|
56
56
|
"coveralls": "3.1.1",
|
|
57
|
-
"cspell": "
|
|
58
|
-
"eslint": "9.
|
|
59
|
-
"globals": "16.
|
|
57
|
+
"cspell": "9.1.3",
|
|
58
|
+
"eslint": "9.30.1",
|
|
59
|
+
"globals": "16.3.0",
|
|
60
60
|
"istanbul": "0.4.5",
|
|
61
61
|
"jasmine-node": "3.0.0",
|
|
62
62
|
"jsdoc": "4.0.4",
|
|
63
63
|
"JSONStream": "1.3.5",
|
|
64
64
|
"tslint": "6.1.3",
|
|
65
|
-
"typescript": "5.8.
|
|
65
|
+
"typescript": "5.8.3"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/typescript/README.md
CHANGED
|
@@ -21,7 +21,7 @@ const {value} = await db.one('SELECT 123 as value');
|
|
|
21
21
|
#### With Extensions
|
|
22
22
|
|
|
23
23
|
The library supports dynamic protocol extensions, via event [extend], which requires
|
|
24
|
-
explicit extension interface to be declared and parameterized, as shown below.
|
|
24
|
+
an explicit extension interface to be declared and parameterized, as shown below.
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
27
|
import * as pgPromise from 'pg-promise';
|
|
@@ -7,17 +7,6 @@
|
|
|
7
7
|
* Removal or modification of this copyright notice is prohibited.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
/////////////////////////////////////////
|
|
11
|
-
// Requires pg-promise v11.0.0 or later.
|
|
12
|
-
/////////////////////////////////////////
|
|
13
|
-
|
|
14
|
-
// We use ES6 as static promise here, because generic promises are still not supported.
|
|
15
|
-
// Follow the links below:
|
|
16
|
-
// https://stackoverflow.com/questions/36593087/using-a-custom-promise-as-a-generic-type
|
|
17
|
-
// https://github.com/Microsoft/TypeScript/issues/1213
|
|
18
|
-
|
|
19
|
-
type XPromise<T> = Promise<T>;
|
|
20
|
-
|
|
21
10
|
import * as pg from './pg-subset';
|
|
22
11
|
import * as pgMinify from 'pg-minify';
|
|
23
12
|
import * as spexLib from 'spex';
|
|
@@ -138,13 +127,13 @@ declare namespace pgPromise {
|
|
|
138
127
|
}
|
|
139
128
|
|
|
140
129
|
interface IPromiseConfig {
|
|
141
|
-
create(resolve: (value?: any) => void, reject?: (reason?: any) => void):
|
|
130
|
+
create(resolve: (value?: any) => void, reject?: (reason?: any) => void): Promise<any>
|
|
142
131
|
|
|
143
132
|
resolve(value?: any): void
|
|
144
133
|
|
|
145
134
|
reject(reason?: any): void
|
|
146
135
|
|
|
147
|
-
all(iterable: any):
|
|
136
|
+
all(iterable: any): Promise<any>
|
|
148
137
|
}
|
|
149
138
|
|
|
150
139
|
type FormattingFilter = '^' | '~' | '#' | ':raw' | ':alias' | ':name' | ':json' | ':csv' | ':list' | ':value';
|
|
@@ -308,7 +297,7 @@ declare namespace pgPromise {
|
|
|
308
297
|
// We export this interface only to be able to help IntelliSense cast extension types correctly,
|
|
309
298
|
// which doesn't always work, depending on the version of IntelliSense being used.
|
|
310
299
|
interface IDatabase<Ext, C extends pg.IClient = pg.IClient> extends IBaseProtocol<Ext> {
|
|
311
|
-
connect(options?: IConnectionOptions<C>):
|
|
300
|
+
connect(options?: IConnectionOptions<C>): Promise<IConnected<Ext, C>>
|
|
312
301
|
|
|
313
302
|
/////////////////////////////////////////////////////////////////////////////
|
|
314
303
|
// Hidden, read-only properties, for integrating with third-party libraries:
|
|
@@ -369,89 +358,89 @@ declare namespace pgPromise {
|
|
|
369
358
|
interface IBaseProtocol<Ext> {
|
|
370
359
|
|
|
371
360
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#query
|
|
372
|
-
query<T = any>(query: QueryParam, values?: any, qrm?: queryResult):
|
|
361
|
+
query<T = any>(query: QueryParam, values?: any, qrm?: queryResult): Promise<T>
|
|
373
362
|
|
|
374
363
|
// result-specific methods;
|
|
375
364
|
|
|
376
365
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#none
|
|
377
|
-
none(query: QueryParam, values?: any):
|
|
366
|
+
none(query: QueryParam, values?: any): Promise<null>
|
|
378
367
|
|
|
379
368
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#one
|
|
380
|
-
one<T = any>(query: QueryParam, values?: any, cb?: (value: any) => T, thisArg?: any):
|
|
369
|
+
one<T = any>(query: QueryParam, values?: any, cb?: (value: any) => T, thisArg?: any): Promise<T>
|
|
381
370
|
|
|
382
371
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#oneOrNone
|
|
383
|
-
oneOrNone<T = any>(query: QueryParam, values?: any, cb?: (value: any) => T, thisArg?: any):
|
|
372
|
+
oneOrNone<T = any>(query: QueryParam, values?: any, cb?: (value: any) => T, thisArg?: any): Promise<T | null>
|
|
384
373
|
|
|
385
374
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#many
|
|
386
|
-
many<T = any>(query: QueryParam, values?: any):
|
|
375
|
+
many<T = any>(query: QueryParam, values?: any): Promise<T[]>
|
|
387
376
|
|
|
388
377
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#manyOrNone
|
|
389
|
-
manyOrNone<T = any>(query: QueryParam, values?: any):
|
|
378
|
+
manyOrNone<T = any>(query: QueryParam, values?: any): Promise<T[]>
|
|
390
379
|
|
|
391
380
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#any
|
|
392
|
-
any<T = any>(query: QueryParam, values?: any):
|
|
381
|
+
any<T = any>(query: QueryParam, values?: any): Promise<T[]>
|
|
393
382
|
|
|
394
383
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#result
|
|
395
|
-
result<T, R = IResultExt<T>>(query: QueryParam, values?: any, cb?: (value: IResultExt<T>) => R, thisArg?: any):
|
|
384
|
+
result<T, R = IResultExt<T>>(query: QueryParam, values?: any, cb?: (value: IResultExt<T>) => R, thisArg?: any): Promise<R>
|
|
396
385
|
|
|
397
386
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#multiResult
|
|
398
|
-
multiResult(query: QueryParam, values?: any):
|
|
387
|
+
multiResult(query: QueryParam, values?: any): Promise<pg.IResult[]>
|
|
399
388
|
|
|
400
389
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#multi
|
|
401
|
-
multi<T = any>(query: QueryParam, values?: any):
|
|
390
|
+
multi<T = any>(query: QueryParam, values?: any): Promise<Array<T[]>>
|
|
402
391
|
|
|
403
392
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#stream
|
|
404
|
-
stream(qs: NodeJS.ReadableStream, init: (stream: NodeJS.ReadableStream) => void):
|
|
393
|
+
stream(qs: NodeJS.ReadableStream, init: (stream: NodeJS.ReadableStream) => void): Promise<{
|
|
405
394
|
processed: number,
|
|
406
395
|
duration: number
|
|
407
396
|
}>
|
|
408
397
|
|
|
409
398
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#func
|
|
410
|
-
func<T = any>(funcName: string, values?: any, qrm?: queryResult):
|
|
399
|
+
func<T = any>(funcName: string, values?: any, qrm?: queryResult): Promise<T>
|
|
411
400
|
|
|
412
401
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#proc
|
|
413
|
-
proc<T = any>(procName: string, values?: any, cb?: (value: any) => T, thisArg?: any):
|
|
402
|
+
proc<T = any>(procName: string, values?: any, cb?: (value: any) => T, thisArg?: any): Promise<T | null>
|
|
414
403
|
|
|
415
404
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#map
|
|
416
|
-
map<T = any>(query: QueryParam, values: any, cb: (row: any, index: number, data: any[]) => T, thisArg?: any):
|
|
405
|
+
map<T = any>(query: QueryParam, values: any, cb: (row: any, index: number, data: any[]) => T, thisArg?: any): Promise<T[]>
|
|
417
406
|
|
|
418
407
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#each
|
|
419
|
-
each<T = any>(query: QueryParam, values: any, cb: (row: any, index: number, data: any[]) => void, thisArg?: any):
|
|
408
|
+
each<T = any>(query: QueryParam, values: any, cb: (row: any, index: number, data: any[]) => void, thisArg?: any): Promise<T[]>
|
|
420
409
|
|
|
421
410
|
// Tasks;
|
|
422
411
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#task
|
|
423
|
-
task<T>(cb: (t: ITask<Ext> & Ext) => T |
|
|
412
|
+
task<T>(cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
424
413
|
|
|
425
|
-
task<T>(tag: string | number, cb: (t: ITask<Ext> & Ext) => T |
|
|
414
|
+
task<T>(tag: string | number, cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
426
415
|
|
|
427
|
-
task<T>(options: { tag?: any }, cb: (t: ITask<Ext> & Ext) => T |
|
|
416
|
+
task<T>(options: { tag?: any }, cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
428
417
|
|
|
429
418
|
// Conditional Tasks;
|
|
430
419
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#taskIf
|
|
431
|
-
taskIf<T>(cb: (t: ITask<Ext> & Ext) => T |
|
|
420
|
+
taskIf<T>(cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
432
421
|
|
|
433
|
-
taskIf<T>(tag: string | number, cb: (t: ITask<Ext> & Ext) => T |
|
|
422
|
+
taskIf<T>(tag: string | number, cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
434
423
|
|
|
435
|
-
taskIf<T>(options: ITaskIfOptions<Ext>, cb: (t: ITask<Ext> & Ext) => T |
|
|
424
|
+
taskIf<T>(options: ITaskIfOptions<Ext>, cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
436
425
|
|
|
437
426
|
// Transactions;
|
|
438
427
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#tx
|
|
439
|
-
tx<T>(cb: (t: ITask<Ext> & Ext) => T |
|
|
428
|
+
tx<T>(cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
440
429
|
|
|
441
|
-
tx<T>(tag: string | number, cb: (t: ITask<Ext> & Ext) => T |
|
|
430
|
+
tx<T>(tag: string | number, cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
442
431
|
|
|
443
432
|
tx<T>(options: {
|
|
444
433
|
tag?: any,
|
|
445
434
|
mode?: _txMode.TransactionMode | null
|
|
446
|
-
}, cb: (t: ITask<Ext> & Ext) => T |
|
|
435
|
+
}, cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
447
436
|
|
|
448
437
|
// Conditional Transactions;
|
|
449
438
|
// API: https://vitaly-t.github.io/pg-promise/Database.html#txIf
|
|
450
|
-
txIf<T>(cb: (t: ITask<Ext> & Ext) => T |
|
|
439
|
+
txIf<T>(cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
451
440
|
|
|
452
|
-
txIf<T>(tag: string | number, cb: (t: ITask<Ext> & Ext) => T |
|
|
441
|
+
txIf<T>(tag: string | number, cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
453
442
|
|
|
454
|
-
txIf<T>(options: ITxIfOptions<Ext>, cb: (t: ITask<Ext> & Ext) => T |
|
|
443
|
+
txIf<T>(options: ITxIfOptions<Ext>, cb: (t: ITask<Ext> & Ext) => T | Promise<T>): Promise<T>
|
|
455
444
|
}
|
|
456
445
|
|
|
457
446
|
// Database object in connected state;
|
|
@@ -465,10 +454,10 @@ declare namespace pgPromise {
|
|
|
465
454
|
|
|
466
455
|
// But for direct connections (connect({direct: true})), `kill` flag is ignored, because
|
|
467
456
|
// the connection is always closed physically, which may take time, and so in this case
|
|
468
|
-
// the method returns a Promise
|
|
469
|
-
done(kill?: boolean): void |
|
|
457
|
+
// the method returns a Promise to indicate when the connection finished closing.
|
|
458
|
+
done(kill?: boolean): void | Promise<void>;
|
|
470
459
|
|
|
471
|
-
// Repeated calls are not allowed
|
|
460
|
+
// Repeated calls are not allowed and will throw an error.
|
|
472
461
|
}
|
|
473
462
|
|
|
474
463
|
// Event context extension for tasks + transactions;
|
|
@@ -508,7 +497,9 @@ declare namespace pgPromise {
|
|
|
508
497
|
cn: any
|
|
509
498
|
dc: any
|
|
510
499
|
query: any
|
|
511
|
-
params: any
|
|
500
|
+
params: any,
|
|
501
|
+
values: any,
|
|
502
|
+
queryFilePath?: string,
|
|
512
503
|
ctx: ITaskContext
|
|
513
504
|
}
|
|
514
505
|
|
|
@@ -607,7 +598,7 @@ declare namespace pgPromise {
|
|
|
607
598
|
|
|
608
599
|
query?(e: IEventContext<C>): void
|
|
609
600
|
|
|
610
|
-
// NOTE: result is undefined when data comes from QueryStream, i.e. via method Database.stream
|
|
601
|
+
// NOTE: The result is undefined when data comes from QueryStream, i.e. via method Database.stream
|
|
611
602
|
receive?(e: { data: any[], result: IResultExt | void, ctx: IEventContext<C> }): void
|
|
612
603
|
|
|
613
604
|
task?(e: IEventContext<C>): void
|
|
@@ -721,13 +712,13 @@ declare namespace pgPromise {
|
|
|
721
712
|
}
|
|
722
713
|
|
|
723
714
|
interface IGenericPromise {
|
|
724
|
-
(cb: (resolve: (value?: any) => void, reject: (reason?: any) => void) => void):
|
|
715
|
+
(cb: (resolve: (value?: any) => void, reject: (reason?: any) => void) => void): Promise<any>
|
|
725
716
|
|
|
726
717
|
resolve(value?: any): void
|
|
727
718
|
|
|
728
719
|
reject(reason?: any): void
|
|
729
720
|
|
|
730
|
-
all(iterable: any):
|
|
721
|
+
all(iterable: any): Promise<any>
|
|
731
722
|
}
|
|
732
723
|
}
|
|
733
724
|
|