pg-promise 10.12.1 → 10.14.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/lib/query.js CHANGED
@@ -167,12 +167,14 @@ function $query(ctx, query, values, qrm, config) {
167
167
  lastResult = result[result.length - 1];
168
168
  for (let i = 0; i < result.length; i++) {
169
169
  const r = result[i];
170
+ makeIterable(r);
170
171
  error = Events.receive(opt, r.rows, r, getContext());
171
172
  if (error) {
172
173
  break;
173
174
  }
174
175
  }
175
176
  } else {
177
+ makeIterable(result);
176
178
  result.duration = Date.now() - start;
177
179
  error = Events.receive(opt, result.rows, result, getContext());
178
180
  }
@@ -258,6 +260,16 @@ function $query(ctx, query, values, qrm, config) {
258
260
  });
259
261
  }
260
262
 
263
+ // Extends Result to provide iterable for the rows;
264
+ //
265
+ // To be removed once the following PR is merged amd released:
266
+ // https://github.com/brianc/node-postgres/pull/2861
267
+ function makeIterable(r) {
268
+ r[Symbol.iterator] = function () {
269
+ return this.rows.values();
270
+ };
271
+ }
272
+
261
273
  module.exports = config => {
262
274
  return function (ctx, query, values, qrm) {
263
275
  return $query.call(this, ctx, query, values, qrm, config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-promise",
3
- "version": "10.12.1",
3
+ "version": "10.14.0",
4
4
  "description": "PostgreSQL interface for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "typings": "typescript/pg-promise.d.ts",
@@ -45,13 +45,13 @@
45
45
  "spex": "3.2.0"
46
46
  },
47
47
  "devDependencies": {
48
- "@types/node": "18.11.0",
48
+ "@types/node": "18.11.9",
49
49
  "bluebird": "3.7.2",
50
50
  "coveralls": "3.1.1",
51
- "eslint": "8.25.0",
51
+ "eslint": "8.27.0",
52
52
  "istanbul": "0.4.5",
53
53
  "jasmine-node": "3.0.0",
54
- "jsdoc": "3.6.11",
54
+ "jsdoc": "4.0.0",
55
55
  "JSONStream": "1.3.5",
56
56
  "pg-query-stream": "4.2.4",
57
57
  "tslint": "6.1.3",
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  /////////////////////////////////////////
11
- // Requires pg-promise v10.5.0 or later.
11
+ // Requires pg-promise v10.14.0 or later.
12
12
  /////////////////////////////////////////
13
13
 
14
14
  // We use ES6 as static promise here, because generic promises are still not supported.
@@ -290,7 +290,7 @@ declare namespace pgPromise {
290
290
  readonly $pool: pg.IPool
291
291
  }
292
292
 
293
- interface IResultExt extends pg.IResult {
293
+ interface IResultExt<T = unknown> extends pg.IResult<T> {
294
294
  // Property 'duration' exists only in the following context:
295
295
  // - for single-query events 'receive'
296
296
  // - for method Database.result
@@ -39,10 +39,10 @@ declare namespace pg {
39
39
  format: string
40
40
  }
41
41
 
42
- interface IResult {
42
+ interface IResult<T = unknown> extends Iterable<T> {
43
43
  command: string
44
44
  rowCount: number
45
- rows: any[]
45
+ rows: T[]
46
46
  fields: IColumn[]
47
47
 
48
48
  // properties below are not available within Native Bindings:
@@ -290,13 +290,13 @@ declare namespace pg {
290
290
 
291
291
  interface IClient extends EventEmitter {
292
292
 
293
- query(config: any, values: any[], callback: (err: Error, result: IResult) => void): undefined
293
+ query<T>(config: any, values: any[], callback: (err: Error, result: IResult<T>) => void): undefined
294
294
 
295
- query(config: any, callback: (err: Error, result: IResult) => void): undefined
295
+ query<T>(config: any, callback: (err: Error, result: IResult<T>) => void): undefined
296
296
 
297
- query(config: any, values: any[]): Promise<IResult>
297
+ query<T>(config: any, values: any[]): Promise<IResult<T>>
298
298
 
299
- query(config: any): Promise<IResult>
299
+ query<T>(config: any): Promise<IResult<T>>
300
300
 
301
301
  connectionParameters: IConnectionParameters
302
302
  database: string