@slonik/pg-driver 47.3.2 → 48.0.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/dist/factories/createPgDriverFactory.d.ts +1 -1
- package/dist/factories/createPgDriverFactory.d.ts.map +1 -1
- package/dist/factories/createPgDriverFactory.js +32 -39
- package/dist/factories/createPgDriverFactory.js.map +1 -1
- package/dist/factories/createPgDriverFactory.test.js +2 -7
- package/dist/factories/createPgDriverFactory.test.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -7
- package/dist/index.js.map +1 -1
- package/package.json +18 -35
- package/src/factories/createPgDriverFactory.ts +12 -12
- package/src/index.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPgDriverFactory.d.ts","sourceRoot":"","sources":["../../src/factories/createPgDriverFactory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createPgDriverFactory.d.ts","sourceRoot":"","sources":["../../src/factories/createPgDriverFactory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,aAAa,EAEd,MAAM,gBAAgB,CAAC;AA2PxB,eAAO,MAAM,qBAAqB,QAAO,aA8HxC,CAAC"}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable canonical/id-match */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const node_stream_1 = require("node:stream");
|
|
12
|
-
const pg_1 = require("pg");
|
|
13
|
-
const pg_query_stream_1 = __importDefault(require("pg-query-stream"));
|
|
14
|
-
const pg_types_1 = require("pg-types");
|
|
15
|
-
const postgres_array_1 = require("postgres-array");
|
|
2
|
+
import { createDriverFactory } from '@slonik/driver';
|
|
3
|
+
import { BackendTerminatedError, BackendTerminatedUnexpectedlyError, CheckExclusionConstraintViolationError, CheckIntegrityConstraintViolationError, ForeignKeyIntegrityConstraintViolationError, IdleTransactionTimeoutError, InputSyntaxError, InvalidInputError, NotNullIntegrityConstraintViolationError, StatementCancelledError, StatementTimeoutError, UnexpectedStateError, UniqueIntegrityConstraintViolationError, } from '@slonik/errors';
|
|
4
|
+
import { parseDsn } from '@slonik/utilities';
|
|
5
|
+
import { Transform } from 'node:stream';
|
|
6
|
+
import { Client } from 'pg';
|
|
7
|
+
import QueryStream from 'pg-query-stream';
|
|
8
|
+
import { getTypeParser as getNativeTypeParser } from 'pg-types';
|
|
9
|
+
import { parse as parseArray } from 'postgres-array';
|
|
16
10
|
const createTypeOverrides = async (connection, typeParsers) => {
|
|
17
11
|
const typeNames = typeParsers.map((typeParser) => {
|
|
18
12
|
return typeParser.name;
|
|
@@ -38,7 +32,7 @@ const createTypeOverrides = async (connection, typeParsers) => {
|
|
|
38
32
|
};
|
|
39
33
|
if (postgresType.typarray) {
|
|
40
34
|
parsers[postgresType.typarray] = (arrayValue) => {
|
|
41
|
-
return (
|
|
35
|
+
return parseArray(arrayValue).map((value) => {
|
|
42
36
|
return typeParser.parse(value);
|
|
43
37
|
});
|
|
44
38
|
};
|
|
@@ -48,11 +42,11 @@ const createTypeOverrides = async (connection, typeParsers) => {
|
|
|
48
42
|
if (parsers[oid]) {
|
|
49
43
|
return parsers[oid];
|
|
50
44
|
}
|
|
51
|
-
return (
|
|
45
|
+
return getNativeTypeParser(oid);
|
|
52
46
|
};
|
|
53
47
|
};
|
|
54
48
|
const createClientConfiguration = (clientConfiguration) => {
|
|
55
|
-
const connectionOptions =
|
|
49
|
+
const connectionOptions = parseDsn(clientConfiguration.connectionUri);
|
|
56
50
|
const poolConfiguration = {
|
|
57
51
|
application_name: connectionOptions.applicationName,
|
|
58
52
|
database: connectionOptions.databaseName,
|
|
@@ -109,7 +103,7 @@ const createClientConfiguration = (clientConfiguration) => {
|
|
|
109
103
|
return poolConfiguration;
|
|
110
104
|
};
|
|
111
105
|
const queryTypeOverrides = async (pgClientConfiguration, driverConfiguration) => {
|
|
112
|
-
const client = new
|
|
106
|
+
const client = new Client(pgClientConfiguration);
|
|
113
107
|
await client.connect();
|
|
114
108
|
const typeOverrides = await createTypeOverrides(client, driverConfiguration.typeParsers);
|
|
115
109
|
await client.end();
|
|
@@ -124,56 +118,56 @@ const isErrorWithCode = (error) => {
|
|
|
124
118
|
// @see https://github.com/gajus/slonik/issues/557
|
|
125
119
|
const wrapError = (error, query) => {
|
|
126
120
|
if (error.message.toLowerCase().includes('connection terminated unexpectedly')) {
|
|
127
|
-
return new
|
|
121
|
+
return new BackendTerminatedUnexpectedlyError(error);
|
|
128
122
|
}
|
|
129
123
|
if (error.message.toLowerCase().includes('connection terminated')) {
|
|
130
|
-
return new
|
|
124
|
+
return new BackendTerminatedError(error);
|
|
131
125
|
}
|
|
132
126
|
if (!isErrorWithCode(error)) {
|
|
133
127
|
return error;
|
|
134
128
|
}
|
|
135
129
|
if (error.code === '22P02') {
|
|
136
|
-
return new
|
|
130
|
+
return new InvalidInputError(error.message);
|
|
137
131
|
}
|
|
138
132
|
if (error.code === '25P03') {
|
|
139
|
-
return new
|
|
133
|
+
return new IdleTransactionTimeoutError(error);
|
|
140
134
|
}
|
|
141
135
|
if (error.code === '57P01') {
|
|
142
|
-
return new
|
|
136
|
+
return new BackendTerminatedError(error);
|
|
143
137
|
}
|
|
144
138
|
if (error.code === '57014' &&
|
|
145
139
|
// The code alone is not enough to distinguish between a statement timeout and a statement cancellation.
|
|
146
140
|
error.message.includes('canceling statement due to user request')) {
|
|
147
|
-
return new
|
|
141
|
+
return new StatementCancelledError(error);
|
|
148
142
|
}
|
|
149
143
|
if (error.code === '57014') {
|
|
150
|
-
return new
|
|
144
|
+
return new StatementTimeoutError(error);
|
|
151
145
|
}
|
|
152
146
|
if (error.code === '23502') {
|
|
153
|
-
return new
|
|
147
|
+
return new NotNullIntegrityConstraintViolationError(error);
|
|
154
148
|
}
|
|
155
149
|
if (error.code === '23503') {
|
|
156
|
-
return new
|
|
150
|
+
return new ForeignKeyIntegrityConstraintViolationError(error);
|
|
157
151
|
}
|
|
158
152
|
if (error.code === '23505') {
|
|
159
|
-
return new
|
|
153
|
+
return new UniqueIntegrityConstraintViolationError(error);
|
|
160
154
|
}
|
|
161
155
|
if (error.code === '23P01') {
|
|
162
|
-
return new
|
|
156
|
+
return new CheckExclusionConstraintViolationError(error);
|
|
163
157
|
}
|
|
164
158
|
if (error.code === '23514') {
|
|
165
|
-
return new
|
|
159
|
+
return new CheckIntegrityConstraintViolationError(error);
|
|
166
160
|
}
|
|
167
161
|
if (error.code === '42601') {
|
|
168
162
|
if (!query) {
|
|
169
|
-
return new
|
|
163
|
+
return new UnexpectedStateError('Expected query to be provided');
|
|
170
164
|
}
|
|
171
|
-
return new
|
|
165
|
+
return new InputSyntaxError(error, query);
|
|
172
166
|
}
|
|
173
167
|
return error;
|
|
174
168
|
};
|
|
175
|
-
const createPgDriverFactory = () => {
|
|
176
|
-
return
|
|
169
|
+
export const createPgDriverFactory = () => {
|
|
170
|
+
return createDriverFactory(async ({ driverConfiguration }) => {
|
|
177
171
|
const clientConfiguration = createClientConfiguration(driverConfiguration);
|
|
178
172
|
// eslint-disable-next-line require-atomic-updates
|
|
179
173
|
clientConfiguration.types = {
|
|
@@ -181,7 +175,7 @@ const createPgDriverFactory = () => {
|
|
|
181
175
|
};
|
|
182
176
|
return {
|
|
183
177
|
createPoolClient: async ({ clientEventEmitter }) => {
|
|
184
|
-
const client = new
|
|
178
|
+
const client = new Client(clientConfiguration);
|
|
185
179
|
// We will see this triggered when the connection is terminated, e.g.
|
|
186
180
|
// "terminates transactions that are idle beyond idleInTransactionSessionTimeout" test.
|
|
187
181
|
const onError = (error) => {
|
|
@@ -217,7 +211,7 @@ const createPgDriverFactory = () => {
|
|
|
217
211
|
});
|
|
218
212
|
}
|
|
219
213
|
if (Array.isArray(result)) {
|
|
220
|
-
throw new
|
|
214
|
+
throw new InvalidInputError('Must not use multiple statements in a single query.');
|
|
221
215
|
}
|
|
222
216
|
return {
|
|
223
217
|
command: result.command,
|
|
@@ -232,7 +226,7 @@ const createPgDriverFactory = () => {
|
|
|
232
226
|
};
|
|
233
227
|
},
|
|
234
228
|
stream: (sql, values) => {
|
|
235
|
-
const stream = client.query(new
|
|
229
|
+
const stream = client.query(new QueryStream(sql, values));
|
|
236
230
|
let fields = [];
|
|
237
231
|
// `rowDescription` will not fire if the query produces a syntax error.
|
|
238
232
|
// Also, `rowDescription` won't fire until client starts consuming the stream.
|
|
@@ -245,7 +239,7 @@ const createPgDriverFactory = () => {
|
|
|
245
239
|
};
|
|
246
240
|
});
|
|
247
241
|
});
|
|
248
|
-
const transform = new
|
|
242
|
+
const transform = new Transform({
|
|
249
243
|
objectMode: true,
|
|
250
244
|
async transform(datum, enc, callback) {
|
|
251
245
|
if (!fields) {
|
|
@@ -272,5 +266,4 @@ const createPgDriverFactory = () => {
|
|
|
272
266
|
};
|
|
273
267
|
});
|
|
274
268
|
};
|
|
275
|
-
exports.createPgDriverFactory = createPgDriverFactory;
|
|
276
269
|
//# sourceMappingURL=createPgDriverFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPgDriverFactory.js","sourceRoot":"","sources":["../../src/factories/createPgDriverFactory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createPgDriverFactory.js","sourceRoot":"","sources":["../../src/factories/createPgDriverFactory.ts"],"names":[],"mappings":"AAAA,uCAAuC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAOrD,OAAO,EACL,sBAAsB,EACtB,kCAAkC,EAClC,sCAAsC,EACtC,sCAAsC,EACtC,2CAA2C,EAC3C,2BAA2B,EAC3B,gBAAgB,EAChB,iBAAiB,EACjB,wCAAwC,EACxC,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,uCAAuC,GACxC,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,QA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E;gCAC3C,OAAO;oCACL,UAAU,EAAE,KAAK,CAAC,UAAU;oCAC5B,IAAI,EAAE,KAAK,CAAC,IAAI;iCACjB,CAAC;4BACJ,CAAC,CAAC,CAAC;wBACL,CAAC,CAAC,CAAC;wBAEH,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC;4BAC9B,UAAU,EAAE,IAAI;4BAChB,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ;gCAClC,IAAI,CAAC,MAAM,EAAE,CAAC;oCACZ,QAAQ,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;oCAE5C,OAAO;gCACT,CAAC;gCAED,IAAI,CAAC,IAAI,CAAC;oCACR,MAAM;oCACN,GAAG,EAAE,KAAK;iCACX,CAAC,CAAC;gCAEH,QAAQ,EAAE,CAAC;4BACb,CAAC;yBACF,CAAC,CAAC;wBAEH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;4BAC3B,SAAS,CAAC,IAAI,CACZ,OAAO,EACP,SAAS,CAAC,KAAK,EAAE;gCACf,GAAG;gCACH,MAAM,EAAE,MAAoC;6BAC7C,CAAC,CACH,CAAC;wBACJ,CAAC,CAAC,CAAC;wBAEH,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAChC,CAAC;iBACF,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const ava_1 = __importDefault(require("ava"));
|
|
7
|
-
(0, ava_1.default)('ok', (t) => {
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
test('ok', (t) => {
|
|
8
3
|
t.pass();
|
|
9
4
|
});
|
|
10
5
|
//# sourceMappingURL=createPgDriverFactory.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPgDriverFactory.test.js","sourceRoot":"","sources":["../../src/factories/createPgDriverFactory.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createPgDriverFactory.test.js","sourceRoot":"","sources":["../../src/factories/createPgDriverFactory.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,KAAK,CAAC;AAEvB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE;IACf,CAAC,CAAC,IAAI,EAAE,CAAC;AACX,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.DatabaseError = exports.createPgDriverFactory = void 0;
|
|
4
|
-
var createPgDriverFactory_1 = require("./factories/createPgDriverFactory");
|
|
5
|
-
Object.defineProperty(exports, "createPgDriverFactory", { enumerable: true, get: function () { return createPgDriverFactory_1.createPgDriverFactory; } });
|
|
6
|
-
var pg_1 = require("pg");
|
|
7
|
-
Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function () { return pg_1.DatabaseError; } });
|
|
1
|
+
export { createPgDriverFactory } from './factories/createPgDriverFactory.js';
|
|
2
|
+
export { DatabaseError } from 'pg';
|
|
8
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"src/**/*.test.ts"
|
|
13
13
|
],
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"nodeArguments": [
|
|
15
|
+
"--import=tsimp"
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@slonik/driver": "^
|
|
20
|
-
"@slonik/errors": "^
|
|
21
|
-
"@slonik/sql-tag": "^
|
|
22
|
-
"@slonik/types": "^
|
|
23
|
-
"@slonik/utilities": "^
|
|
19
|
+
"@slonik/driver": "^48.0.0",
|
|
20
|
+
"@slonik/errors": "^48.0.0",
|
|
21
|
+
"@slonik/sql-tag": "^48.0.0",
|
|
22
|
+
"@slonik/types": "^48.0.0",
|
|
23
|
+
"@slonik/utilities": "^48.0.0",
|
|
24
24
|
"pg": "^8.13.1",
|
|
25
25
|
"pg-query-stream": "^4.9.6",
|
|
26
26
|
"pg-types": "^4.0.2",
|
|
@@ -28,18 +28,18 @@
|
|
|
28
28
|
},
|
|
29
29
|
"description": "A Node.js PostgreSQL client with strict types, detailed logging and assertions.",
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^22.15.
|
|
32
|
-
"@types/pg": "^8.
|
|
31
|
+
"@types/node": "^22.15.19",
|
|
32
|
+
"@types/pg": "^8.15.2",
|
|
33
33
|
"ava": "^6.3.0",
|
|
34
|
-
"cspell": "^
|
|
35
|
-
"eslint": "9.
|
|
36
|
-
"
|
|
37
|
-
"ts-node": "^10.9.1",
|
|
34
|
+
"cspell": "^9.0.1",
|
|
35
|
+
"eslint": "9.27.0",
|
|
36
|
+
"tsimp": "^2.0.12",
|
|
38
37
|
"typescript": "^5.8.3",
|
|
39
|
-
"
|
|
38
|
+
"typescript-eslint": "^8.32.1",
|
|
39
|
+
"@slonik/eslint-config": "^48.0.0"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
42
|
+
"node": ">=24"
|
|
43
43
|
},
|
|
44
44
|
"files": [
|
|
45
45
|
"./src",
|
|
@@ -53,24 +53,6 @@
|
|
|
53
53
|
"license": "BSD-3-Clause",
|
|
54
54
|
"main": "./dist/index.js",
|
|
55
55
|
"name": "@slonik/pg-driver",
|
|
56
|
-
"nyc": {
|
|
57
|
-
"all": true,
|
|
58
|
-
"exclude": [
|
|
59
|
-
"**/*.d.ts"
|
|
60
|
-
],
|
|
61
|
-
"include": [
|
|
62
|
-
"src/**/*.ts"
|
|
63
|
-
],
|
|
64
|
-
"reporter": [
|
|
65
|
-
"html",
|
|
66
|
-
"text-summary"
|
|
67
|
-
],
|
|
68
|
-
"require": [
|
|
69
|
-
"ts-node/register/transpile-only"
|
|
70
|
-
],
|
|
71
|
-
"silent": true,
|
|
72
|
-
"sourceMap": false
|
|
73
|
-
},
|
|
74
56
|
"peerDependencies": {
|
|
75
57
|
"zod": "^3"
|
|
76
58
|
},
|
|
@@ -78,14 +60,15 @@
|
|
|
78
60
|
"type": "git",
|
|
79
61
|
"url": "https://github.com/gajus/slonik"
|
|
80
62
|
},
|
|
63
|
+
"type": "module",
|
|
81
64
|
"types": "./dist/index.d.ts",
|
|
82
|
-
"version": "
|
|
65
|
+
"version": "48.0.0",
|
|
83
66
|
"scripts": {
|
|
84
67
|
"build": "rm -fr ./dist && tsc --project ./tsconfig.json",
|
|
85
68
|
"lint": "npm run lint:cspell && npm run lint:eslint && npm run lint:tsc",
|
|
86
69
|
"lint:cspell": "cspell . --no-progress --gitignore",
|
|
87
70
|
"lint:eslint": "eslint --cache ./src",
|
|
88
71
|
"lint:tsc": "tsc --noEmit",
|
|
89
|
-
"test": "
|
|
72
|
+
"test": "ava --verbose --serial"
|
|
90
73
|
}
|
|
91
74
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable canonical/id-match */
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { createDriverFactory } from '@slonik/driver';
|
|
4
|
+
import type {
|
|
5
|
+
DriverCommand,
|
|
6
|
+
DriverConfiguration,
|
|
7
|
+
DriverFactory,
|
|
8
|
+
DriverTypeParser,
|
|
9
9
|
} from '@slonik/driver';
|
|
10
10
|
import {
|
|
11
11
|
BackendTerminatedError,
|
|
@@ -22,14 +22,14 @@ import {
|
|
|
22
22
|
UnexpectedStateError,
|
|
23
23
|
UniqueIntegrityConstraintViolationError,
|
|
24
24
|
} from '@slonik/errors';
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
25
|
+
import type { PrimitiveValueExpression } from '@slonik/sql-tag';
|
|
26
|
+
import type { Field, Query } from '@slonik/types';
|
|
27
27
|
import { parseDsn } from '@slonik/utilities';
|
|
28
28
|
import { Transform } from 'node:stream';
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
import { Client } from 'pg';
|
|
30
|
+
import type {
|
|
31
|
+
DatabaseError,
|
|
32
|
+
ClientConfig as NativePostgresClientConfiguration,
|
|
33
33
|
} from 'pg';
|
|
34
34
|
import QueryStream from 'pg-query-stream';
|
|
35
35
|
import { getTypeParser as getNativeTypeParser } from 'pg-types';
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createPgDriverFactory } from './factories/createPgDriverFactory';
|
|
1
|
+
export { createPgDriverFactory } from './factories/createPgDriverFactory.js';
|
|
2
2
|
export { DatabaseError } from 'pg';
|