pg-promise 10.10.1 → 10.10.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-promise",
3
- "version": "10.10.1",
3
+ "version": "10.10.2",
4
4
  "description": "PostgreSQL interface for Node.js",
5
5
  "main": "lib/index.js",
6
6
  "typings": "typescript/pg-promise.d.ts",
@@ -41,21 +41,21 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "assert-options": "0.7.0",
44
- "pg": "8.5.1",
44
+ "pg": "8.6.0",
45
45
  "pg-minify": "1.6.2",
46
46
  "spex": "3.2.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@types/node": "14.14.37",
49
+ "@types/node": "15.0.1",
50
50
  "bluebird": "3.7.2",
51
51
  "coveralls": "3.1.0",
52
- "eslint": "7.23.0",
52
+ "eslint": "7.25.0",
53
53
  "istanbul": "0.4.5",
54
54
  "jasmine-node": "3.0.0",
55
55
  "jsdoc": "3.6.6",
56
56
  "JSONStream": "1.3.5",
57
- "pg-query-stream": "4.0.0",
57
+ "pg-query-stream": "4.1.0",
58
58
  "tslint": "6.1.3",
59
- "typescript": "4.2.3"
59
+ "typescript": "4.2.4"
60
60
  }
61
61
  }
@@ -1,6 +1,6 @@
1
1
  ## TypeScript for pg-promise
2
2
 
3
- Complete TypeScript 3.x (`strict` mode) declarations for [pg-promise].
3
+ Complete TypeScript declarations for [pg-promise].
4
4
 
5
5
  ### Inclusion
6
6
 
@@ -14,12 +14,14 @@ import * as pgPromise from 'pg-promise';
14
14
  const pgp = pgPromise({/* Initialization Options */});
15
15
 
16
16
  const db = pgp('postgres://username:password@host:port/database');
17
+
18
+ const {value} = await db.one('SELECT 123 as value');
17
19
  ```
18
20
 
19
21
  #### With Extensions
20
22
 
21
23
  The library supports dynamic protocol extensions, via event [extend], which requires
22
- explicit extension interface to be declared, and parameterized as shown below.
24
+ explicit extension interface to be declared and parameterized, as shown below.
23
25
 
24
26
  ```ts
25
27
  import * as pgPromise from 'pg-promise';
@@ -33,7 +35,7 @@ interface IExtensions {
33
35
  const options: pgPromise.IInitOptions<IExtensions> = {
34
36
  extend(obj) {
35
37
  obj.findUser = userId => {
36
- return obj.one('SELECT * FROM Users WHERE id = $1', userId);
38
+ return obj.one('SELECT * FROM Users WHERE id = $1', [userId]);
37
39
  }
38
40
  }
39
41
  };
@@ -44,11 +46,17 @@ const pgp = pgPromise(options);
44
46
  // database object:
45
47
  const db = pgp('postgres://username:password@host:port/database');
46
48
 
47
- // now you can use the extensions everywhere (including tasks and transactions):
48
- db.findUser(123).then(...);
49
+ // protocol is extended on each level:
50
+ const user = await db.findUser(123);
51
+
52
+ // ...including inside tasks and transactions:
53
+ await db.task(async t => {
54
+ const user = await t.findUser(123);
55
+ // ...etc
56
+ });
49
57
  ```
50
58
 
51
- For a complete and comprehensive example, check out [pg-promise-demo].
59
+ For a comprehensive example, check out [pg-promise-demo].
52
60
 
53
61
  [pg-promise-demo]:https://github.com/vitaly-t/pg-promise-demo
54
62
  [extend]:http://vitaly-t.github.io/pg-promise/global.html#event:extend
@@ -579,7 +579,8 @@ declare namespace pgPromise {
579
579
 
580
580
  query?(e: IEventContext<C>): void
581
581
 
582
- receive?(data: any[], result: IResultExt, e: IEventContext<C>): void
582
+ // NOTE: result is undefined when data comes from QueryStream, i.e. via method Database.stream
583
+ receive?(data: any[], result: IResultExt | void, e: IEventContext<C>): void
583
584
 
584
585
  task?(e: IEventContext<C>): void
585
586