@devmoods/express-extras 0.13.8 → 0.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.
@@ -1,6 +1,6 @@
1
- import { Pool, PoolConfig } from 'pg';
2
- import { SQL, SQLStatement } from 'sql-template-strings';
3
- export interface PostgresOptions extends PoolConfig {
1
+ import pg from 'pg';
2
+ import { SQL, type SQLStatement } from 'sql-template-strings';
3
+ export interface PostgresOptions extends pg.PoolConfig {
4
4
  onError?: (error: Error, client: any) => void;
5
5
  }
6
6
  export declare class DoesNotExistError extends Error {
@@ -19,168 +19,168 @@ export declare class MultipleRowsReturnedError extends Error {
19
19
  export declare function createPostgres({ onError, ...config }?: PostgresOptions): {
20
20
  withConnection: (callback: (query: {
21
21
  query: {
22
- <T extends import("pg").Submittable>(queryStream: T): T;
23
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
24
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
25
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
26
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
27
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
28
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
22
+ <T extends pg.Submittable>(queryStream: T): T;
23
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
24
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
25
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
26
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
27
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
28
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
29
29
  };
30
30
  first: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
31
31
  query: {
32
- <T extends import("pg").Submittable>(queryStream: T): T;
33
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
34
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
35
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
36
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
37
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
38
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
32
+ <T extends pg.Submittable>(queryStream: T): T;
33
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
34
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
35
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
36
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
37
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
38
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
39
39
  };
40
40
  }) => Promise<T_1 | null>;
41
41
  all: <T_2>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
42
42
  query: {
43
- <T extends import("pg").Submittable>(queryStream: T): T;
44
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
45
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
46
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
47
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
48
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
49
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
43
+ <T extends pg.Submittable>(queryStream: T): T;
44
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
45
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
46
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
47
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
48
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
49
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
50
50
  };
51
51
  }) => Promise<T_2[]>;
52
52
  get: <T_3>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
53
53
  query: {
54
- <T extends import("pg").Submittable>(queryStream: T): T;
55
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
56
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
57
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
58
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
59
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
60
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
54
+ <T extends pg.Submittable>(queryStream: T): T;
55
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
56
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
57
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
58
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
59
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
60
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
61
61
  };
62
62
  }) => Promise<T_3>;
63
63
  insert: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
64
64
  query: {
65
- <T extends import("pg").Submittable>(queryStream: T): T;
66
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
67
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
68
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
69
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
70
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
71
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
65
+ <T extends pg.Submittable>(queryStream: T): T;
66
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
67
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
68
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
69
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
70
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
71
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
72
72
  };
73
73
  }) => Promise<T_1 | null>;
74
74
  }) => Promise<void>) => Promise<void>;
75
75
  transaction: <T_4>(callback: (query: {
76
76
  query: {
77
- <T extends import("pg").Submittable>(queryStream: T): T;
78
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
79
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
80
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
81
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
82
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
83
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
77
+ <T extends pg.Submittable>(queryStream: T): T;
78
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
79
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
80
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
81
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
82
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
83
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
84
84
  };
85
85
  first: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
86
86
  query: {
87
- <T extends import("pg").Submittable>(queryStream: T): T;
88
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
89
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
90
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
91
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
92
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
93
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
87
+ <T extends pg.Submittable>(queryStream: T): T;
88
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
89
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
90
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
91
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
92
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
93
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
94
94
  };
95
95
  }) => Promise<T_1 | null>;
96
96
  all: <T_2>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
97
97
  query: {
98
- <T extends import("pg").Submittable>(queryStream: T): T;
99
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
100
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
101
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
102
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
103
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
104
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
98
+ <T extends pg.Submittable>(queryStream: T): T;
99
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
100
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
101
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
102
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
103
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
104
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
105
105
  };
106
106
  }) => Promise<T_2[]>;
107
107
  get: <T_3>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
108
108
  query: {
109
- <T extends import("pg").Submittable>(queryStream: T): T;
110
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
111
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
112
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
113
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
114
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
115
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
109
+ <T extends pg.Submittable>(queryStream: T): T;
110
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
111
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
112
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
113
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
114
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
115
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
116
116
  };
117
117
  }) => Promise<T_3>;
118
118
  insert: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
119
119
  query: {
120
- <T extends import("pg").Submittable>(queryStream: T): T;
121
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
122
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
123
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
124
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
125
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
126
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
120
+ <T extends pg.Submittable>(queryStream: T): T;
121
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
122
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
123
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
124
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
125
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
126
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
127
127
  };
128
128
  }) => Promise<T_1 | null>;
129
129
  }) => T_4 | Promise<T_4>) => Promise<T_4>;
130
- instance: Pool;
130
+ instance: pg.Pool;
131
131
  clear: (force?: boolean) => Promise<void>;
132
132
  end(): Promise<void>;
133
133
  query: {
134
- <T extends import("pg").Submittable>(queryStream: T): T;
135
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
136
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
137
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
138
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
139
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
140
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
134
+ <T extends pg.Submittable>(queryStream: T): T;
135
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
136
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
137
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
138
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
139
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
140
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
141
141
  };
142
142
  first: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
143
143
  query: {
144
- <T extends import("pg").Submittable>(queryStream: T): T;
145
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
146
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
147
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
148
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
149
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
150
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
144
+ <T extends pg.Submittable>(queryStream: T): T;
145
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
146
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
147
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
148
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
149
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
150
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
151
151
  };
152
152
  }) => Promise<T_1 | null>;
153
153
  all: <T_2>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
154
154
  query: {
155
- <T extends import("pg").Submittable>(queryStream: T): T;
156
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
157
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
158
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
159
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
160
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
161
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
155
+ <T extends pg.Submittable>(queryStream: T): T;
156
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
157
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
158
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
159
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
160
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
161
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
162
162
  };
163
163
  }) => Promise<T_2[]>;
164
164
  get: <T_3>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
165
165
  query: {
166
- <T extends import("pg").Submittable>(queryStream: T): T;
167
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
168
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
169
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
170
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
171
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
172
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
166
+ <T extends pg.Submittable>(queryStream: T): T;
167
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
168
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
169
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
170
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
171
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
172
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
173
173
  };
174
174
  }) => Promise<T_3>;
175
175
  insert: <T_1>(text: string | SQLStatement, values?: (null | string | number | Date)[], options?: {
176
176
  query: {
177
- <T extends import("pg").Submittable>(queryStream: T): T;
178
- <R extends any[] = any[], I extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I>, values?: I | undefined): Promise<import("pg").QueryArrayResult<R>>;
179
- <R_1 extends import("pg").QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: import("pg").QueryConfig<I_1>): Promise<import("pg").QueryResult<R_1>>;
180
- <R_2 extends import("pg").QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_2>, values?: I_2 | undefined): Promise<import("pg").QueryResult<R_2>>;
181
- <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: import("pg").QueryArrayConfig<I_3>, callback: (err: Error, result: import("pg").QueryArrayResult<R_3>) => void): void;
182
- <R_4 extends import("pg").QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | import("pg").QueryConfig<I_4>, callback: (err: Error, result: import("pg").QueryResult<R_4>) => void): void;
183
- <R_5 extends import("pg").QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: import("pg").QueryResult<R_5>) => void): void;
177
+ <T extends pg.Submittable>(queryStream: T): T;
178
+ <R extends any[] = any[], I extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I>, values?: I | undefined): Promise<pg.QueryArrayResult<R>>;
179
+ <R_1 extends pg.QueryResultRow = any, I_1 extends any[] = any[]>(queryConfig: pg.QueryConfig<I_1>): Promise<pg.QueryResult<R_1>>;
180
+ <R_2 extends pg.QueryResultRow = any, I_2 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_2>, values?: I_2 | undefined): Promise<pg.QueryResult<R_2>>;
181
+ <R_3 extends any[] = any[], I_3 extends any[] = any[]>(queryConfig: pg.QueryArrayConfig<I_3>, callback: (err: Error, result: pg.QueryArrayResult<R_3>) => void): void;
182
+ <R_4 extends pg.QueryResultRow = any, I_4 extends any[] = any[]>(queryTextOrConfig: string | pg.QueryConfig<I_4>, callback: (err: Error, result: pg.QueryResult<R_4>) => void): void;
183
+ <R_5 extends pg.QueryResultRow = any, I_5 extends any[] = any[]>(queryText: string, values: I_5, callback: (err: Error, result: pg.QueryResult<R_5>) => void): void;
184
184
  };
185
185
  }) => Promise<T_1 | null>;
186
186
  };
package/dist/postgres.js CHANGED
@@ -1,22 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sql = exports.createPostgres = exports.MultipleRowsReturnedError = exports.DoesNotExistError = void 0;
4
- const pg_1 = require("pg");
5
- const sql_template_strings_1 = require("sql-template-strings");
6
- class DoesNotExistError extends Error {
1
+ import pg from 'pg';
2
+ import { SQL } from 'sql-template-strings';
3
+ export class DoesNotExistError extends Error {
7
4
  constructor(message) {
8
5
  super(message);
9
6
  this.name = 'DoesNotExistError';
10
7
  }
11
8
  }
12
- exports.DoesNotExistError = DoesNotExistError;
13
- class MultipleRowsReturnedError extends Error {
9
+ export class MultipleRowsReturnedError extends Error {
14
10
  constructor(message) {
15
11
  super(message);
16
12
  this.name = 'MultipleRowsReturnedError';
17
13
  }
18
14
  }
19
- exports.MultipleRowsReturnedError = MultipleRowsReturnedError;
20
15
  /**
21
16
  * Create a new Postgres connection pool with
22
17
  * conveience methods for executing queries using
@@ -24,8 +19,8 @@ exports.MultipleRowsReturnedError = MultipleRowsReturnedError;
24
19
  *
25
20
  * @param config
26
21
  */
27
- function createPostgres({ onError = () => { }, ...config } = {}) {
28
- const pool = new pg_1.Pool(config);
22
+ export function createPostgres({ onError = () => { }, ...config } = {}) {
23
+ const pool = new pg.Pool(config);
29
24
  pool.on('error', onError);
30
25
  const defaultQuery = pool.query.bind(pool);
31
26
  async function withConnection(callback) {
@@ -34,9 +29,6 @@ function createPostgres({ onError = () => { }, ...config } = {}) {
34
29
  const result = await callback(makeQueryFunctions(client.query.bind(client)));
35
30
  return result;
36
31
  }
37
- catch (error) {
38
- throw error;
39
- }
40
32
  finally {
41
33
  client.release();
42
34
  }
@@ -106,5 +98,4 @@ function createPostgres({ onError = () => { }, ...config } = {}) {
106
98
  },
107
99
  };
108
100
  }
109
- exports.createPostgres = createPostgres;
110
- exports.sql = sql_template_strings_1.SQL;
101
+ export const sql = SQL;