@prairielearn/postgres 1.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.
File without changes
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # `@prairielearn/postgres`
2
+
3
+ Tools for loading and executing Postgres queries.
4
+
5
+ ## Usage
6
+
7
+ Before making any queries, you must initialize the library with your connection details and an error handler:
8
+
9
+ ```ts
10
+ import sqldb from '@prairielearn/postgres';
11
+
12
+ function idleErrorHandler(err: any) {
13
+ console.error(err);
14
+ process.exit(1);
15
+ }
16
+
17
+ await sqldb.initAsync(
18
+ {
19
+ user: '...',
20
+ database: '...',
21
+ host: '...',
22
+ password: '...',
23
+ max: 2,
24
+ idleTimeoutMillis: 30000,
25
+ },
26
+ idleErrorHandler
27
+ );
28
+ ```
29
+
30
+ The options argument accepts any values that the [`pg.Pool`](https://node-postgres.com/apis/pool) constructor does.
31
+
32
+ ### Loading queries from files
33
+
34
+ The recommended way to write queries is to store them in a `.sql` file adjacent to the file from which they'll be used. For instance, if we want to make some queries in an `index.js` file, we can put the following in `index.sql`:
35
+
36
+ ```sql
37
+ -- BLOCK select_user
38
+ SELECT * FROM users WHERE id = $user_id;
39
+
40
+ -- BLOCK select_course
41
+ SELECT * FROM courses WHERE id = $course_id;
42
+ ```
43
+
44
+ You can then load these queries in your JavaScript file:
45
+
46
+ ```ts
47
+ import sqldb from '@prairielearn/postgres';
48
+ const sql = sqldb.loadSqlEquiv(import.meta.url);
49
+
50
+ console.log(sql.select_user);
51
+ console.log(sql.select_course);
52
+
53
+ // Or, if you're working in a CommonJS file:
54
+ const sqldb = require('@prairielearn/postgres');
55
+ const sql = sqldb.loadSqlEquiv(__filename);
56
+ ```
57
+
58
+ ### Making queries
59
+
60
+ Once you've loaded your SQL, you can use them to query the database:
61
+
62
+ ```ts
63
+ import sqldb from '@prairielearn/postgres';
64
+ const sql = sqldb.loadSqlEquiv(import.meta.url);
65
+
66
+ const result = await sqldb.queryAsync(sql.select_user, { user_id: '1' });
67
+ console.log(result.rows);
68
+ ```
69
+
70
+ The `queryAsync` function returns a [`pg.Result`](https://node-postgres.com/apis/result) object; see linked documentation for a list of additional properties that are available on that object.
71
+
72
+ There are a variety of utility methods that can make assertions about the results:
73
+
74
+ - `queryOneRowAsync`: Throws an error if the result doesn't have exactly one row.
75
+ - `queryZeroOrOneRowAsync`: Throws an error if the result has more than one row.
76
+
77
+ ### Stored procedures (sprocs)
78
+
79
+ There are also functions that make it easy to call a stored procedure with a given set of arguments. Consider a database that has the following sproc defined:
80
+
81
+ ```sql
82
+ CREATE PROCEDURE insert_data(a integer, b integer)
83
+ LANGUAGE SQL
84
+ BEGIN ATOMIC
85
+ INSERT INTO tbl VALUES (a);
86
+ INSERT INTO tbl VALUES (b);
87
+ END;
88
+ ```
89
+
90
+ You can call this sproc in your JavaScript code:
91
+
92
+ ```ts
93
+ await sqldb.callAsync('insert_data', [1, 2]);
94
+ ```
95
+
96
+ ### Transactions
97
+
98
+ To use transactions, wrap your queries with the `runInTransaction` function:
99
+
100
+ ```ts
101
+ await sqldb.runInTransaction(async () => {
102
+ await sqldb.queryAsync(sql.insert_user, { name: 'Kevin Young' });
103
+ await sqldb.queryAsync(sql.insert_course, { rubric: 'CS 101' });
104
+ });
105
+ ```
106
+
107
+ `runInTransaction` will start a transaction and then execute the provided function. Any nested query will use the same client and thus run inside the transaction. If the function throws an error, the transaction is rolled back; otherwise, it is committed.
108
+
109
+ ### Callback-style functions
110
+
111
+ For most functions that return promises, there are corresponding versions that work with Node-style callbacks:
112
+
113
+ ```ts
114
+ sqldb.query(sql.select_user, (err, result) => {
115
+ if (err) {
116
+ console.error('Error running query', err);
117
+ } else {
118
+ console.log(result.rows);
119
+ }
120
+ });
121
+ ```
122
+
123
+ However, these should be avoided in new code:
124
+
125
+ - They make it more difficult to correctly handle errors
126
+ - Callback-style code tends to be more verbose and suffer from "callback hell"
@@ -0,0 +1,3 @@
1
+ export { loadSql, loadSqlEquiv } from './loader';
2
+ export * from './pool';
3
+ export { PoolClient } from 'pg';
package/dist/index.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.loadSqlEquiv = exports.loadSql = void 0;
18
+ var loader_1 = require("./loader");
19
+ Object.defineProperty(exports, "loadSql", { enumerable: true, get: function () { return loader_1.loadSql; } });
20
+ Object.defineProperty(exports, "loadSqlEquiv", { enumerable: true, get: function () { return loader_1.loadSqlEquiv; } });
21
+ __exportStar(require("./pool"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAiD;AAAxC,iGAAA,OAAO,OAAA;AAAE,sGAAA,YAAY,OAAA;AAC9B,yCAAuB"}
@@ -0,0 +1,4 @@
1
+ type SqlFile = Record<string, string>;
2
+ export declare function loadSql(filename: string): SqlFile;
3
+ export declare function loadSqlEquiv(filePathOrUrl: string): SqlFile;
4
+ export {};
package/dist/loader.js ADDED
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadSqlEquiv = exports.loadSql = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const node_url_1 = __importDefault(require("node:url"));
10
+ function loadSql(filename) {
11
+ const sql = {};
12
+ sql.all = node_fs_1.default.readFileSync(filename, 'utf8');
13
+ const lines = sql.all.split(/\r?\n/);
14
+ const blockRE = /^ *-- *BLOCK +([^ ]+) *$/;
15
+ let blockName = null;
16
+ lines.forEach((line) => {
17
+ var result = blockRE.exec(line);
18
+ if (result) {
19
+ blockName = result[1];
20
+ if (sql[blockName])
21
+ throw new Error(`${filename}: duplicate BLOCK name: ${blockName}`);
22
+ sql[blockName] = line;
23
+ }
24
+ else if (blockName) {
25
+ sql[blockName] += '\n' + line;
26
+ }
27
+ });
28
+ return sql;
29
+ }
30
+ exports.loadSql = loadSql;
31
+ function loadSqlEquiv(filePathOrUrl) {
32
+ let resolvedPath = filePathOrUrl;
33
+ // This allows for us to pass `import.meta.url` to this function in ES Modules
34
+ // environments where `__filename` is not available.
35
+ if (filePathOrUrl.startsWith('file://')) {
36
+ resolvedPath = node_url_1.default.fileURLToPath(filePathOrUrl);
37
+ }
38
+ const components = node_path_1.default.parse(resolvedPath);
39
+ components.ext = '.sql';
40
+ const sqlFilename = node_path_1.default.join(components.dir, components.name) + components.ext;
41
+ return loadSql(sqlFilename);
42
+ }
43
+ exports.loadSqlEquiv = loadSqlEquiv;
44
+ //# sourceMappingURL=loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,wDAA2B;AAI3B,SAAgB,OAAO,CAAC,QAAgB;IACtC,MAAM,GAAG,GAAY,EAAE,CAAC;IACxB,GAAG,CAAC,GAAG,GAAG,iBAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,0BAA0B,CAAC;IAC3C,IAAI,SAAS,GAAkB,IAAI,CAAC;IACpC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,MAAM,EAAE;YACV,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,GAAG,CAAC,SAAS,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,2BAA2B,SAAS,EAAE,CAAC,CAAC;YACvF,GAAG,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;SACvB;aAAM,IAAI,SAAS,EAAE;YACpB,GAAG,CAAC,SAAS,CAAC,IAAI,IAAI,GAAG,IAAI,CAAC;SAC/B;IACH,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC;AAjBD,0BAiBC;AAED,SAAgB,YAAY,CAAC,aAAqB;IAChD,IAAI,YAAY,GAAG,aAAa,CAAC;IAEjC,8EAA8E;IAC9E,oDAAoD;IACpD,IAAI,aAAa,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QACvC,YAAY,GAAG,kBAAG,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;KACjD;IAED,MAAM,UAAU,GAAG,mBAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC5C,UAAU,CAAC,GAAG,GAAG,MAAM,CAAC;IACxB,MAAM,WAAW,GAAG,mBAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC;IAChF,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC;AAC9B,CAAC;AAbD,oCAaC"}
package/dist/pool.d.ts ADDED
@@ -0,0 +1,256 @@
1
+ /// <reference types="node" />
2
+ import pg, { QueryResult } from 'pg';
3
+ type Params = Record<string, any> | any[];
4
+ export declare class PostgresError extends Error {
5
+ data: Record<string, any>;
6
+ constructor(message: string, data: Record<string, any>);
7
+ }
8
+ export declare class PostgresPool {
9
+ /** The pool from which clients will be acquired. */
10
+ private pool;
11
+ /**
12
+ * We use this to propagate the client associated with the current transaction
13
+ * to any nested queries. In the past, we had some nasty bugs associated with
14
+ * the fact that we tried to acquire new clients inside of transactions, which
15
+ * ultimately lead to a deadlock.
16
+ */
17
+ private alsClient;
18
+ private searchSchema;
19
+ /**
20
+ * Creates a new connection pool and attempts to connect to the database.
21
+ */
22
+ initAsync(pgConfig: pg.PoolConfig, idleErrorHandler: (error: Error, client: pg.PoolClient) => void): Promise<void>;
23
+ /**
24
+ * Creates a new connection pool and attempts to connect to the database.
25
+ */
26
+ init: (arg1: pg.PoolConfig, arg2: (error: Error, client: pg.PoolClient) => void, callback: (err: NodeJS.ErrnoException) => void) => void;
27
+ /**
28
+ * Closes the connection pool.
29
+ */
30
+ closeAsync(): Promise<void>;
31
+ /**
32
+ * Closes the connection pool.
33
+ */
34
+ close: (callback: (err: NodeJS.ErrnoException) => void) => void;
35
+ /**
36
+ * Gets a new client from the connection pool. If `err` is not null
37
+ * then `client` and `done` are undefined. If `err` is null then
38
+ * `client` is valid and can be used. The caller MUST call `done()` to
39
+ * release the client, whether or not errors occurred while using
40
+ * `client`. The client can call `done(truthy_value)` to force
41
+ * destruction of the client, but this should not be used except in
42
+ * unusual circumstances.
43
+ */
44
+ getClientAsync(): Promise<pg.PoolClient>;
45
+ /**
46
+ * Gets a new client from the connection pool.
47
+ */
48
+ getClient(callback: (error: Error | null, client?: pg.PoolClient, done?: () => void) => void): void;
49
+ /**
50
+ * Performs a query with the given client.
51
+ */
52
+ queryWithClientAsync(client: pg.PoolClient, sql: string, params: Params): Promise<pg.QueryResult>;
53
+ /**
54
+ * Performs a query with the given client.
55
+ */
56
+ queryWithClient: (arg1: pg.PoolClient, arg2: string, arg3: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
57
+ /**
58
+ * Performs a query with the given client. Errors if the query returns more
59
+ * than one row.
60
+ */
61
+ queryWithClientOneRowAsync(client: pg.PoolClient, sql: string, params: Params): Promise<pg.QueryResult>;
62
+ /**
63
+ * Performs a query with the given client. Errors if the query returns more
64
+ * than one row.
65
+ */
66
+ queryWithClientOneRow: (arg1: pg.PoolClient, arg2: string, arg3: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
67
+ /**
68
+ * Performs a query with the given client. Errors if the query returns more
69
+ * than one row.
70
+ */
71
+ queryWithClientZeroOrOneRowAsync(client: pg.PoolClient, sql: string, params: Params): Promise<QueryResult>;
72
+ /**
73
+ * Performs a query with the given client. Errors if the query returns more
74
+ * than one row.
75
+ */
76
+ queryWithClientZeroOrOneRow: (arg1: pg.PoolClient, arg2: string, arg3: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
77
+ /**
78
+ * Rolls back the current transaction for the given client.
79
+ */
80
+ rollbackWithClientAsync(client: pg.PoolClient): Promise<void>;
81
+ /**
82
+ * Rolls back the current transaction for the given client.
83
+ */
84
+ rollbackWithClient(client: pg.PoolClient, _done: (release?: any) => void, callback: (err: Error | null) => void): void;
85
+ /**
86
+ * Begins a new transaction.
87
+ */
88
+ beginTransactionAsync(): Promise<pg.PoolClient>;
89
+ /**
90
+ * Commits the transaction if err is null, otherwise rollbacks the transaction.
91
+ * Also releases the client.
92
+ */
93
+ endTransactionAsync(client: pg.PoolClient, err: Error | null | undefined): Promise<void>;
94
+ /**
95
+ * Commits the transaction if err is null, otherwise rollbacks the transaction.
96
+ * Also releases the client.
97
+ */
98
+ endTransaction(client: pg.PoolClient, _done: (rollback?: any) => void, err: Error | null | undefined, callback: (error: Error | null) => void): void;
99
+ /**
100
+ * Runs the specified function inside of a transaction. The function will
101
+ * receive a database client as an argument, but it can also make queries
102
+ * as usual, and the correct client will be used automatically.
103
+ *
104
+ * The transaction will be rolled back if the function throws an error, and
105
+ * will be committed otherwise.
106
+ */
107
+ runInTransactionAsync(fn: (client: pg.PoolClient) => Promise<void>): Promise<void>;
108
+ /**
109
+ * Executes a query with the specified parameters.
110
+ */
111
+ queryAsync(sql: string, params: Params): Promise<QueryResult>;
112
+ /**
113
+ * Executes a query with the specified parameters.
114
+ */
115
+ query: (arg1: string, arg2: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
116
+ /**
117
+ * Executes a query with the specified parameters. Errors if the query does
118
+ * not return exactly one row.
119
+ */
120
+ queryOneRowAsync(sql: string, params: Params): Promise<pg.QueryResult>;
121
+ /**
122
+ * Executes a query with the specified parameters. Errors if the query does
123
+ * not return exactly one row.
124
+ */
125
+ queryOneRow: (arg1: string, arg2: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
126
+ /**
127
+ * Executes a query with the specified parameters. Errors if the query
128
+ * returns more than one row.
129
+ */
130
+ queryZeroOrOneRowAsync(sql: string, params: Params): Promise<pg.QueryResult>;
131
+ /**
132
+ * Executes a query with the specified parameters. Errors if the query
133
+ * returns more than one row.
134
+ */
135
+ queryZeroOrOneRow: (arg1: string, arg2: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
136
+ /**
137
+ * Calls the given function with the specified parameters.
138
+ */
139
+ callAsync(functionName: string, params: any[]): Promise<pg.QueryResult>;
140
+ /**
141
+ * Calls the given function with the specified parameters.
142
+ */
143
+ call: (arg1: string, arg2: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
144
+ /**
145
+ * Calls the given function with the specified parameters. Errors if the
146
+ * function does not return exactly one row.
147
+ */
148
+ callOneRowAsync(functionName: string, params: any[]): Promise<pg.QueryResult>;
149
+ /**
150
+ * Calls the given function with the specified parameters. Errors if the
151
+ * function does not return exactly one row.
152
+ */
153
+ callOneRow: (arg1: string, arg2: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
154
+ /**
155
+ * Calls the given function with the specified parameters. Errors if the
156
+ * function returns more than one row.
157
+ */
158
+ callZeroOrOneRowAsync(functionName: string, params: any[]): Promise<pg.QueryResult>;
159
+ /**
160
+ * Calls the given function with the specified parameters. Errors if the
161
+ * function returns more than one row.
162
+ */
163
+ callZeroOrOneRow: (arg1: string, arg2: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
164
+ /**
165
+ * Calls a function with the specified parameters using a specific client.
166
+ */
167
+ callWithClientAsync(client: pg.PoolClient, functionName: string, params: any[]): Promise<pg.QueryResult>;
168
+ /**
169
+ * Calls a function with the specified parameters using a specific client.
170
+ */
171
+ callWithClient: (arg1: pg.PoolClient, arg2: string, arg3: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
172
+ /**
173
+ * Calls a function with the specified parameters using a specific client.
174
+ * Errors if the function does not return exactly one row.
175
+ */
176
+ callWithClientOneRowAsync(client: pg.PoolClient, functionName: string, params: any[]): Promise<pg.QueryResult>;
177
+ /**
178
+ * Calls a function with the specified parameters using a specific client.
179
+ * Errors if the function does not return exactly one row.
180
+ */
181
+ callWithClientOneRow: (arg1: pg.PoolClient, arg2: string, arg3: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
182
+ /**
183
+ * Calls a function with the specified parameters using a specific client.
184
+ * Errors if the function returns more than one row.
185
+ */
186
+ callWithClientZeroOrOneRowAsync(client: pg.PoolClient, functionName: string, params: any[]): Promise<pg.QueryResult>;
187
+ /**
188
+ * Calls a function with the specified parameters using a specific client.
189
+ * Errors if the function returns more than one row.
190
+ */
191
+ callWithClientZeroOrOneRow: (arg1: pg.PoolClient, arg2: string, arg3: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
192
+ /**
193
+ * Set the schema to use for the search path.
194
+ *
195
+ * @param schema The schema name to use (can be "null" to unset the search path)
196
+ */
197
+ setSearchSchema(schema: string): Promise<void>;
198
+ /**
199
+ * Get the schema that is currently used for the search path.
200
+ *
201
+ * @return schema in use (may be `null` to indicate no schema)
202
+ */
203
+ getSearchSchema(): string | null;
204
+ /**
205
+ * Generate, set, and return a random schema name.
206
+ *
207
+ * @param prefix The prefix of the new schema, only the first 28 characters will be used (after lowercasing).
208
+ * @returns The randomly-generated search schema.
209
+ */
210
+ setRandomSearchSchemaAsync(prefix: string): Promise<string>;
211
+ /**
212
+ * Generate, set, and return a random schema name.
213
+ */
214
+ setRandomSearchSchema: (arg1: string, callback: (err: NodeJS.ErrnoException, result: string) => void) => void;
215
+ }
216
+ export declare const init: (arg1: pg.PoolConfig, arg2: (error: Error, client: pg.PoolClient) => void, callback: (err: NodeJS.ErrnoException) => void) => void;
217
+ export declare const initAsync: (pgConfig: pg.PoolConfig, idleErrorHandler: (error: Error, client: pg.PoolClient) => void) => Promise<void>;
218
+ export declare const close: (callback: (err: NodeJS.ErrnoException) => void) => void;
219
+ export declare const closeAsync: () => Promise<void>;
220
+ export declare const getClientAsync: () => Promise<pg.PoolClient>;
221
+ export declare const getClient: (callback: (error: Error | null, client?: pg.PoolClient, done?: () => void) => void) => void;
222
+ export declare const queryWithClient: (arg1: pg.PoolClient, arg2: string, arg3: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
223
+ export declare const queryWithClientAsync: (client: pg.PoolClient, sql: string, params: Params) => Promise<pg.QueryResult>;
224
+ export declare const queryWithClientOneRow: (arg1: pg.PoolClient, arg2: string, arg3: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
225
+ export declare const queryWithClientOneRowAsync: (client: pg.PoolClient, sql: string, params: Params) => Promise<pg.QueryResult>;
226
+ export declare const queryWithClientZeroOrOneRow: (arg1: pg.PoolClient, arg2: string, arg3: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
227
+ export declare const queryWithClientZeroOrOneRowAsync: (client: pg.PoolClient, sql: string, params: Params) => Promise<QueryResult>;
228
+ export declare const rollbackWithClientAsync: (client: pg.PoolClient) => Promise<void>;
229
+ export declare const rollbackWithClient: (client: pg.PoolClient, _done: (release?: any) => void, callback: (err: Error | null) => void) => void;
230
+ export declare const beginTransactionAsync: () => Promise<pg.PoolClient>;
231
+ export declare const endTransactionAsync: (client: pg.PoolClient, err: Error | null | undefined) => Promise<void>;
232
+ export declare const endTransaction: (client: pg.PoolClient, _done: (rollback?: any) => void, err: Error | null | undefined, callback: (error: Error | null) => void) => void;
233
+ export declare const runInTransactionAsync: (fn: (client: pg.PoolClient) => Promise<void>) => Promise<void>;
234
+ export declare const query: (arg1: string, arg2: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
235
+ export declare const queryAsync: (sql: string, params: Params) => Promise<QueryResult>;
236
+ export declare const queryOneRow: (arg1: string, arg2: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
237
+ export declare const queryOneRowAsync: (sql: string, params: Params) => Promise<pg.QueryResult>;
238
+ export declare const queryZeroOrOneRow: (arg1: string, arg2: Params, callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
239
+ export declare const queryZeroOrOneRowAsync: (sql: string, params: Params) => Promise<pg.QueryResult>;
240
+ export declare const call: (arg1: string, arg2: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
241
+ export declare const callAsync: (functionName: string, params: any[]) => Promise<pg.QueryResult>;
242
+ export declare const callOneRow: (arg1: string, arg2: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
243
+ export declare const callOneRowAsync: (functionName: string, params: any[]) => Promise<pg.QueryResult>;
244
+ export declare const callZeroOrOneRow: (arg1: string, arg2: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
245
+ export declare const callZeroOrOneRowAsync: (functionName: string, params: any[]) => Promise<pg.QueryResult>;
246
+ export declare const callWithClient: (arg1: pg.PoolClient, arg2: string, arg3: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
247
+ export declare const callWithClientAsync: (client: pg.PoolClient, functionName: string, params: any[]) => Promise<pg.QueryResult>;
248
+ export declare const callWithClientOneRow: (arg1: pg.PoolClient, arg2: string, arg3: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
249
+ export declare const callWithClientOneRowAsync: (client: pg.PoolClient, functionName: string, params: any[]) => Promise<pg.QueryResult>;
250
+ export declare const callWithClientZeroOrOneRow: (arg1: pg.PoolClient, arg2: string, arg3: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
251
+ export declare const callWithClientZeroOrOneRowAsync: (client: pg.PoolClient, functionName: string, params: any[]) => Promise<pg.QueryResult>;
252
+ export declare const setSearchSchema: (schema: string) => Promise<void>;
253
+ export declare const getSearchSchema: () => string | null;
254
+ export declare const setRandomSearchSchema: (arg1: string, callback: (err: NodeJS.ErrnoException, result: string) => void) => void;
255
+ export declare const setRandomSearchSchemaAsync: (prefix: string) => Promise<string>;
256
+ export {};