@prairielearn/postgres 1.0.0 → 1.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @prairielearn/postgres
2
+
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 41398700a: Add query functions with Zod-powered validation
package/README.md CHANGED
@@ -35,10 +35,20 @@ The recommended way to write queries is to store them in a `.sql` file adjacent
35
35
 
36
36
  ```sql
37
37
  -- BLOCK select_user
38
- SELECT * FROM users WHERE id = $user_id;
38
+ SELECT
39
+ *
40
+ FROM
41
+ users
42
+ WHERE
43
+ id = $user_id;
39
44
 
40
45
  -- BLOCK select_course
41
- SELECT * FROM courses WHERE id = $course_id;
46
+ SELECT
47
+ *
48
+ FROM
49
+ courses
50
+ WHERE
51
+ id = $course_id;
42
52
  ```
43
53
 
44
54
  You can then load these queries in your JavaScript file:
@@ -79,11 +89,18 @@ There are a variety of utility methods that can make assertions about the result
79
89
  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
90
 
81
91
  ```sql
82
- CREATE PROCEDURE insert_data(a integer, b integer)
83
- LANGUAGE SQL
92
+ CREATE PROCEDURE insert_data (a integer, b integer) LANGUAGE SQL
84
93
  BEGIN ATOMIC
85
- INSERT INTO tbl VALUES (a);
86
- INSERT INTO tbl VALUES (b);
94
+ INSERT INTO
95
+ tbl
96
+ VALUES
97
+ (a);
98
+
99
+ INSERT INTO
100
+ tbl
101
+ VALUES
102
+ (b);
103
+
87
104
  END;
88
105
  ```
89
106
 
@@ -93,14 +110,47 @@ You can call this sproc in your JavaScript code:
93
110
  await sqldb.callAsync('insert_data', [1, 2]);
94
111
  ```
95
112
 
113
+ ### Zod validation
114
+
115
+ For increased safety and confidence, you can describe the shape of data you expect from the database with a [Zod](https://zod.dev/) schema. You can then provide this schema when making a query, and the data returned from the database will be parsed with that schema.
116
+
117
+ ```ts
118
+ import { z } from 'zod';
119
+ import { loadSqlEquiv, queryValidatedRows } from '@prairielearn/postgres';
120
+
121
+ const sql = loadSqlEquiv(import.meta.url);
122
+
123
+ const User = z.object({
124
+ name: z.string(),
125
+ email: z.string(),
126
+ age: z.number(),
127
+ });
128
+
129
+ const users = await queryValidatedOneRow(sql.select_user, { user_id: 1 }, User);
130
+ console.log(users[0].name);
131
+ ```
132
+
133
+ As with the non-validated query functions, there are several variants available:
134
+
135
+ - `queryValidatedRows`
136
+ - `queryValidatedOneRow`
137
+ - `queryValidatedZeroOrOneRow`
138
+ - `queryValidatedSingleColumnRows`
139
+ - `queryValidatedSingleColumnOneRow`
140
+ - `queryValidatedSingleColumnZeroOrOneRow`
141
+ - `callValidatedRows`
142
+ - `callValidatedOneRow`
143
+ - `callValidatedZeroOrOneRow`
144
+
96
145
  ### Transactions
97
146
 
98
- To use transactions, wrap your queries with the `runInTransaction` function:
147
+ To use transactions, wrap your queries with the `runInTransactionAsync` function:
99
148
 
100
149
  ```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' });
150
+ const { user, course } = await sqldb.runInTransactionAsync(async () => {
151
+ const user = await sqldb.queryAsync(sql.insert_user, { name: 'Kevin Young' });
152
+ const course = await sqldb.queryAsync(sql.insert_course, { rubric: 'CS 101' });
153
+ return { user, course };
104
154
  });
105
155
  ```
106
156
 
@@ -0,0 +1,50 @@
1
+ /// <reference types="node" />
2
+ export declare const init: (arg1: import("pg").PoolConfig, arg2: (error: Error, client: import("pg").PoolClient) => void, callback: (err: NodeJS.ErrnoException) => void) => void;
3
+ export declare const initAsync: (pgConfig: import("pg").PoolConfig, idleErrorHandler: (error: Error, client: import("pg").PoolClient) => void) => Promise<void>;
4
+ export declare const close: (callback: (err: NodeJS.ErrnoException) => void) => void;
5
+ export declare const closeAsync: () => Promise<void>;
6
+ export declare const getClientAsync: () => Promise<import("pg").PoolClient>;
7
+ export declare const getClient: (callback: (error: Error | null, client?: import("pg").PoolClient | undefined, done?: (() => void) | undefined) => void) => void;
8
+ export declare const queryWithClient: (arg1: import("pg").PoolClient, arg2: string, arg3: any[] | Record<string, any>, callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
9
+ export declare const queryWithClientAsync: (client: import("pg").PoolClient, sql: string, params: any[] | Record<string, any>) => Promise<import("pg").QueryResult<any>>;
10
+ export declare const queryWithClientOneRow: (arg1: import("pg").PoolClient, arg2: string, arg3: any[] | Record<string, any>, callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
11
+ export declare const queryWithClientOneRowAsync: (client: import("pg").PoolClient, sql: string, params: any[] | Record<string, any>) => Promise<import("pg").QueryResult<any>>;
12
+ export declare const queryWithClientZeroOrOneRow: (arg1: import("pg").PoolClient, arg2: string, arg3: any[] | Record<string, any>, callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
13
+ export declare const queryWithClientZeroOrOneRowAsync: (client: import("pg").PoolClient, sql: string, params: any[] | Record<string, any>) => Promise<import("pg").QueryResult<any>>;
14
+ export declare const rollbackWithClientAsync: (client: import("pg").PoolClient) => Promise<void>;
15
+ export declare const rollbackWithClient: (client: import("pg").PoolClient, _done: (release?: any) => void, callback: (err: Error | null) => void) => void;
16
+ export declare const beginTransactionAsync: () => Promise<import("pg").PoolClient>;
17
+ export declare const endTransactionAsync: (client: import("pg").PoolClient, err: Error | null | undefined) => Promise<void>;
18
+ export declare const endTransaction: (client: import("pg").PoolClient, _done: (rollback?: any) => void, err: Error | null | undefined, callback: (error: Error | null) => void) => void;
19
+ export declare const runInTransactionAsync: <T>(fn: (client: import("pg").PoolClient) => Promise<T>) => Promise<T>;
20
+ export declare const query: (arg1: string, arg2: any[] | Record<string, any>, callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
21
+ export declare const queryAsync: (sql: string, params: any[] | Record<string, any>) => Promise<import("pg").QueryResult<any>>;
22
+ export declare const queryOneRow: (arg1: string, arg2: any[] | Record<string, any>, callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
23
+ export declare const queryOneRowAsync: (sql: string, params: any[] | Record<string, any>) => Promise<import("pg").QueryResult<any>>;
24
+ export declare const queryZeroOrOneRow: (arg1: string, arg2: any[] | Record<string, any>, callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
25
+ export declare const queryZeroOrOneRowAsync: (sql: string, params: any[] | Record<string, any>) => Promise<import("pg").QueryResult<any>>;
26
+ export declare const call: (arg1: string, arg2: any[], callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
27
+ export declare const callAsync: (functionName: string, params: any[]) => Promise<import("pg").QueryResult<any>>;
28
+ export declare const callOneRow: (arg1: string, arg2: any[], callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
29
+ export declare const callOneRowAsync: (functionName: string, params: any[]) => Promise<import("pg").QueryResult<any>>;
30
+ export declare const callZeroOrOneRow: (arg1: string, arg2: any[], callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
31
+ export declare const callZeroOrOneRowAsync: (functionName: string, params: any[]) => Promise<import("pg").QueryResult<any>>;
32
+ export declare const callWithClient: (arg1: import("pg").PoolClient, arg2: string, arg3: any[], callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
33
+ export declare const callWithClientAsync: (client: import("pg").PoolClient, functionName: string, params: any[]) => Promise<import("pg").QueryResult<any>>;
34
+ export declare const callWithClientOneRow: (arg1: import("pg").PoolClient, arg2: string, arg3: any[], callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
35
+ export declare const callWithClientOneRowAsync: (client: import("pg").PoolClient, functionName: string, params: any[]) => Promise<import("pg").QueryResult<any>>;
36
+ export declare const callWithClientZeroOrOneRow: (arg1: import("pg").PoolClient, arg2: string, arg3: any[], callback: (err: NodeJS.ErrnoException | null, result: import("pg").QueryResult<any>) => void) => void;
37
+ export declare const callWithClientZeroOrOneRowAsync: (client: import("pg").PoolClient, functionName: string, params: any[]) => Promise<import("pg").QueryResult<any>>;
38
+ export declare const queryValidatedRows: <Model extends import("zod").ZodTypeAny>(query: string, params: Record<string, any>, model: Model) => Promise<import("zod").TypeOf<Model>[]>;
39
+ export declare const queryValidatedOneRow: <Model extends import("zod").ZodTypeAny>(query: string, params: Record<string, any>, model: Model) => Promise<import("zod").TypeOf<Model>>;
40
+ export declare const queryValidatedZeroOrOneRow: <Model extends import("zod").ZodTypeAny>(query: string, params: Record<string, any>, model: Model) => Promise<import("zod").TypeOf<Model> | null>;
41
+ export declare const queryValidatedSingleColumnRows: <Model extends import("zod").ZodTypeAny>(query: string, params: Record<string, any>, model: Model) => Promise<import("zod").TypeOf<Model>[]>;
42
+ export declare const queryValidatedSingleColumnOneRow: <Model extends import("zod").ZodTypeAny>(query: string, params: Record<string, any>, model: Model) => Promise<import("zod").TypeOf<Model>>;
43
+ export declare const queryValidatedSingleColumnZeroOrOneRow: <Model extends import("zod").ZodTypeAny>(query: string, params: Record<string, any>, model: Model) => Promise<import("zod").TypeOf<Model> | null>;
44
+ export declare const callValidatedRows: <Model extends import("zod").ZodTypeAny>(sprocName: string, params: any[], model: Model) => Promise<import("zod").TypeOf<Model>[]>;
45
+ export declare const callValidatedOneRow: <Model extends import("zod").ZodTypeAny>(sprocName: string, params: any[], model: Model) => Promise<import("zod").TypeOf<Model>>;
46
+ export declare const callValidatedZeroOrOneRow: <Model extends import("zod").ZodTypeAny>(sprocName: string, params: any[], model: Model) => Promise<import("zod").TypeOf<Model> | null>;
47
+ export declare const setSearchSchema: (schema: string) => Promise<void>;
48
+ export declare const getSearchSchema: () => string | null;
49
+ export declare const setRandomSearchSchema: (arg1: string, callback: (err: NodeJS.ErrnoException, result: string) => void) => void;
50
+ export declare const setRandomSearchSchemaAsync: (prefix: string) => Promise<string>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setRandomSearchSchemaAsync = exports.setRandomSearchSchema = exports.getSearchSchema = exports.setSearchSchema = exports.callValidatedZeroOrOneRow = exports.callValidatedOneRow = exports.callValidatedRows = exports.queryValidatedSingleColumnZeroOrOneRow = exports.queryValidatedSingleColumnOneRow = exports.queryValidatedSingleColumnRows = exports.queryValidatedZeroOrOneRow = exports.queryValidatedOneRow = exports.queryValidatedRows = exports.callWithClientZeroOrOneRowAsync = exports.callWithClientZeroOrOneRow = exports.callWithClientOneRowAsync = exports.callWithClientOneRow = exports.callWithClientAsync = exports.callWithClient = exports.callZeroOrOneRowAsync = exports.callZeroOrOneRow = exports.callOneRowAsync = exports.callOneRow = exports.callAsync = exports.call = exports.queryZeroOrOneRowAsync = exports.queryZeroOrOneRow = exports.queryOneRowAsync = exports.queryOneRow = exports.queryAsync = exports.query = exports.runInTransactionAsync = exports.endTransaction = exports.endTransactionAsync = exports.beginTransactionAsync = exports.rollbackWithClient = exports.rollbackWithClientAsync = exports.queryWithClientZeroOrOneRowAsync = exports.queryWithClientZeroOrOneRow = exports.queryWithClientOneRowAsync = exports.queryWithClientOneRow = exports.queryWithClientAsync = exports.queryWithClient = exports.getClient = exports.getClientAsync = exports.closeAsync = exports.close = exports.initAsync = exports.init = void 0;
4
+ const pool_1 = require("./pool");
5
+ const defaultPool = new pool_1.PostgresPool();
6
+ // We re-expose all functions from the default pool here to account for the
7
+ // default case of a shared global pool of clients. If someone want to create
8
+ // their own pool, we expose the `PostgresPool` class.
9
+ //
10
+ // Note that we explicitly bind all functions to `defaultPool`. This ensures
11
+ // that they'll be invoked with the correct `this` context, specifically when
12
+ // this module is imported as `import * as db from '...'` and that import is
13
+ // subsequently transformed by Babel to `interopRequireWildcard(...)`.
14
+ exports.init = defaultPool.init.bind(defaultPool);
15
+ exports.initAsync = defaultPool.initAsync.bind(defaultPool);
16
+ exports.close = defaultPool.close.bind(defaultPool);
17
+ exports.closeAsync = defaultPool.closeAsync.bind(defaultPool);
18
+ exports.getClientAsync = defaultPool.getClientAsync.bind(defaultPool);
19
+ exports.getClient = defaultPool.getClient.bind(defaultPool);
20
+ exports.queryWithClient = defaultPool.queryWithClient.bind(defaultPool);
21
+ exports.queryWithClientAsync = defaultPool.queryWithClientAsync.bind(defaultPool);
22
+ exports.queryWithClientOneRow = defaultPool.queryWithClientOneRow.bind(defaultPool);
23
+ exports.queryWithClientOneRowAsync = defaultPool.queryWithClientOneRowAsync.bind(defaultPool);
24
+ exports.queryWithClientZeroOrOneRow = defaultPool.queryWithClientZeroOrOneRow.bind(defaultPool);
25
+ exports.queryWithClientZeroOrOneRowAsync = defaultPool.queryWithClientZeroOrOneRowAsync.bind(defaultPool);
26
+ exports.rollbackWithClientAsync = defaultPool.rollbackWithClientAsync.bind(defaultPool);
27
+ exports.rollbackWithClient = defaultPool.rollbackWithClient.bind(defaultPool);
28
+ exports.beginTransactionAsync = defaultPool.beginTransactionAsync.bind(defaultPool);
29
+ exports.endTransactionAsync = defaultPool.endTransactionAsync.bind(defaultPool);
30
+ exports.endTransaction = defaultPool.endTransaction.bind(defaultPool);
31
+ exports.runInTransactionAsync = defaultPool.runInTransactionAsync.bind(defaultPool);
32
+ exports.query = defaultPool.query.bind(defaultPool);
33
+ exports.queryAsync = defaultPool.queryAsync.bind(defaultPool);
34
+ exports.queryOneRow = defaultPool.queryOneRow.bind(defaultPool);
35
+ exports.queryOneRowAsync = defaultPool.queryOneRowAsync.bind(defaultPool);
36
+ exports.queryZeroOrOneRow = defaultPool.queryZeroOrOneRow.bind(defaultPool);
37
+ exports.queryZeroOrOneRowAsync = defaultPool.queryZeroOrOneRowAsync.bind(defaultPool);
38
+ exports.call = defaultPool.call.bind(defaultPool);
39
+ exports.callAsync = defaultPool.callAsync.bind(defaultPool);
40
+ exports.callOneRow = defaultPool.callOneRow.bind(defaultPool);
41
+ exports.callOneRowAsync = defaultPool.callOneRowAsync.bind(defaultPool);
42
+ exports.callZeroOrOneRow = defaultPool.callZeroOrOneRow.bind(defaultPool);
43
+ exports.callZeroOrOneRowAsync = defaultPool.callZeroOrOneRowAsync.bind(defaultPool);
44
+ exports.callWithClient = defaultPool.callWithClient.bind(defaultPool);
45
+ exports.callWithClientAsync = defaultPool.callWithClientAsync.bind(defaultPool);
46
+ exports.callWithClientOneRow = defaultPool.callWithClientOneRow.bind(defaultPool);
47
+ exports.callWithClientOneRowAsync = defaultPool.callWithClientOneRowAsync.bind(defaultPool);
48
+ exports.callWithClientZeroOrOneRow = defaultPool.callWithClientZeroOrOneRow.bind(defaultPool);
49
+ exports.callWithClientZeroOrOneRowAsync = defaultPool.callWithClientZeroOrOneRowAsync.bind(defaultPool);
50
+ exports.queryValidatedRows = defaultPool.queryValidatedRows.bind(defaultPool);
51
+ exports.queryValidatedOneRow = defaultPool.queryValidatedOneRow.bind(defaultPool);
52
+ exports.queryValidatedZeroOrOneRow = defaultPool.queryValidatedZeroOrOneRow.bind(defaultPool);
53
+ exports.queryValidatedSingleColumnRows = defaultPool.queryValidatedSingleColumnRows.bind(defaultPool);
54
+ exports.queryValidatedSingleColumnOneRow = defaultPool.queryValidatedSingleColumnOneRow.bind(defaultPool);
55
+ exports.queryValidatedSingleColumnZeroOrOneRow = defaultPool.queryValidatedSingleColumnZeroOrOneRow.bind(defaultPool);
56
+ exports.callValidatedRows = defaultPool.callValidatedRows.bind(defaultPool);
57
+ exports.callValidatedOneRow = defaultPool.callValidatedOneRow.bind(defaultPool);
58
+ exports.callValidatedZeroOrOneRow = defaultPool.callValidatedZeroOrOneRow.bind(defaultPool);
59
+ exports.setSearchSchema = defaultPool.setSearchSchema.bind(defaultPool);
60
+ exports.getSearchSchema = defaultPool.getSearchSchema.bind(defaultPool);
61
+ exports.setRandomSearchSchema = defaultPool.setRandomSearchSchema.bind(defaultPool);
62
+ exports.setRandomSearchSchemaAsync = defaultPool.setRandomSearchSchemaAsync.bind(defaultPool);
63
+ //# sourceMappingURL=default-pool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-pool.js","sourceRoot":"","sources":["../src/default-pool.ts"],"names":[],"mappings":";;;AAAA,iCAAsC;AAEtC,MAAM,WAAW,GAAG,IAAI,mBAAY,EAAE,CAAC;AAEvC,2EAA2E;AAC3E,6EAA6E;AAC7E,sDAAsD;AACtD,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,sEAAsE;AACzD,QAAA,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC1C,QAAA,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACpD,QAAA,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC5C,QAAA,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACtD,QAAA,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC9D,QAAA,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACpD,QAAA,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAChE,QAAA,oBAAoB,GAAG,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC1E,QAAA,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC5E,QAAA,0BAA0B,GAAG,WAAW,CAAC,0BAA0B,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACtF,QAAA,2BAA2B,GACtC,WAAW,CAAC,2BAA2B,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC/C,QAAA,gCAA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C,GACjD,WAAW,CAAC,sCAAsC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC1D,QAAA,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACpE,QAAA,mBAAmB,GAAG,WAAW,CAAC,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACxE,QAAA,yBAAyB,GAAG,WAAW,CAAC,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACpF,QAAA,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAChE,QAAA,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAChE,QAAA,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC5E,QAAA,0BAA0B,GAAG,WAAW,CAAC,0BAA0B,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC"}
File without changes
@@ -24,7 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const chai_1 = require("chai");
27
- const pgPool = __importStar(require("./pool"));
27
+ const pool_1 = require("./pool");
28
+ const pgPool = __importStar(require("./default-pool"));
28
29
  /**
29
30
  * Returns true if the property on `PostgresPool` should be considered
30
31
  * hidden - that is, if it should be available on the module's exports.
@@ -41,7 +42,7 @@ function isHiddenProperty(property) {
41
42
  }
42
43
  describe('sqldb', () => {
43
44
  it('exports the full PostgresPool interface', () => {
44
- const pool = new pgPool.PostgresPool();
45
+ const pool = new pool_1.PostgresPool();
45
46
  Object.getOwnPropertyNames(pool)
46
47
  .filter((n) => !isHiddenProperty(n))
47
48
  .forEach((prop) => {
@@ -54,7 +55,7 @@ describe('sqldb', () => {
54
55
  });
55
56
  });
56
57
  it('should not have extra properties', () => {
57
- const pool = new pgPool.PostgresPool();
58
+ const pool = new pool_1.PostgresPool();
58
59
  const knownProperties = [
59
60
  ...Object.getOwnPropertyNames(pool),
60
61
  ...Object.getOwnPropertyNames(Object.getPrototypeOf(pool)),
@@ -65,4 +66,4 @@ describe('sqldb', () => {
65
66
  });
66
67
  });
67
68
  });
68
- //# sourceMappingURL=pool.test.js.map
69
+ //# sourceMappingURL=default-pool.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-pool.test.js","sourceRoot":"","sources":["../src/default-pool.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,iCAAsC;AACtC,uDAAyC;AAEzC;;;GAGG;AACH,SAAS,gBAAgB,CAAC,QAAgB;IACxC,QAAQ,QAAQ,EAAE;QAChB,KAAK,MAAM,CAAC;QACZ,KAAK,WAAW,CAAC;QACjB,KAAK,cAAc;YACjB,OAAO,IAAI,CAAC;QACd;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC;AAED,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,IAAI,GAAG,IAAI,mBAAY,EAAE,CAAC;QAEhC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC;aAC7B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;aACnC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAChB,aAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC9B,aAAM,CAAC,EAAE,CAAE,MAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QAEL,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACvE,aAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC9B,aAAM,CAAC,EAAE,CAAE,MAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,IAAI,GAAG,IAAI,mBAAY,EAAE,CAAC;QAEhC,MAAM,eAAe,GAAG;YACtB,GAAG,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC;YACnC,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC1D,cAAc;SACf,CAAC;QAEF,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAChD,aAAM,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- export { loadSql, loadSqlEquiv } from './loader';
2
- export * from './pool';
3
1
  export { PoolClient } from 'pg';
2
+ export { loadSql, loadSqlEquiv } from './loader';
3
+ export { PostgresPool } from './pool';
4
+ export * from './default-pool';
package/dist/index.js CHANGED
@@ -14,9 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.loadSqlEquiv = exports.loadSql = void 0;
17
+ exports.PostgresPool = exports.loadSqlEquiv = exports.loadSql = void 0;
18
18
  var loader_1 = require("./loader");
19
19
  Object.defineProperty(exports, "loadSql", { enumerable: true, get: function () { return loader_1.loadSql; } });
20
20
  Object.defineProperty(exports, "loadSqlEquiv", { enumerable: true, get: function () { return loader_1.loadSqlEquiv; } });
21
- __exportStar(require("./pool"), exports);
21
+ var pool_1 = require("./pool");
22
+ Object.defineProperty(exports, "PostgresPool", { enumerable: true, get: function () { return pool_1.PostgresPool; } });
23
+ __exportStar(require("./default-pool"), exports);
22
24
  //# 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":";;;;;;;;;;;;;;;;;AAAA,mCAAiD;AAAxC,iGAAA,OAAO,OAAA;AAAE,sGAAA,YAAY,OAAA;AAC9B,yCAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,mCAAiD;AAAxC,iGAAA,OAAO,OAAA;AAAE,sGAAA,YAAY,OAAA;AAC9B,+BAAsC;AAA7B,oGAAA,YAAY,OAAA;AACrB,iDAA+B"}
package/dist/pool.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import pg, { QueryResult } from 'pg';
3
+ import { z } from 'zod';
3
4
  type Params = Record<string, any> | any[];
4
5
  export declare class PostgresError extends Error {
5
6
  data: Record<string, any>;
@@ -104,7 +105,7 @@ export declare class PostgresPool {
104
105
  * The transaction will be rolled back if the function throws an error, and
105
106
  * will be committed otherwise.
106
107
  */
107
- runInTransactionAsync(fn: (client: pg.PoolClient) => Promise<void>): Promise<void>;
108
+ runInTransactionAsync<T>(fn: (client: pg.PoolClient) => Promise<T>): Promise<T>;
108
109
  /**
109
110
  * Executes a query with the specified parameters.
110
111
  */
@@ -189,6 +190,56 @@ export declare class PostgresPool {
189
190
  * Errors if the function returns more than one row.
190
191
  */
191
192
  callWithClientZeroOrOneRow: (arg1: pg.PoolClient, arg2: string, arg3: any[], callback: (err: NodeJS.ErrnoException | null, result: pg.QueryResult<any>) => void) => void;
193
+ /**
194
+ * Wrapper around {@link queryAsync} that validates that the returned data
195
+ * matches the given validation model. Returns only the rows of the query.
196
+ */
197
+ queryValidatedRows<Model extends z.ZodTypeAny>(query: string, params: Record<string, any>, model: Model): Promise<z.infer<Model>[]>;
198
+ /**
199
+ * Wrapper around {@link queryOneRowAsync} that validates that the returned data
200
+ * matches the given validation model. Returns only a single row of the query.
201
+ */
202
+ queryValidatedOneRow<Model extends z.ZodTypeAny>(query: string, params: Record<string, any>, model: Model): Promise<z.infer<Model>>;
203
+ /**
204
+ * Wrapper around {@link queryZeroOrOneRowAsync} that validates that the
205
+ * returned data matches the given validation model, if it return anything.
206
+ * Returns either the single row of the query or `null`.
207
+ */
208
+ queryValidatedZeroOrOneRow<Model extends z.ZodTypeAny>(query: string, params: Record<string, any>, model: Model): Promise<z.infer<Model> | null>;
209
+ /**
210
+ * Wrapper around {@link queryAsync} that validates that only one column is
211
+ * returned and the data in it matches the given validation model. Returns only
212
+ * the single column of the query as an array.
213
+ */
214
+ queryValidatedSingleColumnRows<Model extends z.ZodTypeAny>(query: string, params: Record<string, any>, model: Model): Promise<z.infer<Model>[]>;
215
+ /**
216
+ * Wrapper around {@link queryOneRowAsync} that validates that only one column
217
+ * is returned and the data in it matches the given validation model. Returns
218
+ * only the single entry.
219
+ */
220
+ queryValidatedSingleColumnOneRow<Model extends z.ZodTypeAny>(query: string, params: Record<string, any>, model: Model): Promise<z.infer<Model>>;
221
+ /**
222
+ * Wrapper around {@link queryZeroOrOneRowAsync} that validates that only one
223
+ * column is returned and the data in it matches the given validation model, if
224
+ * it return anything. Returns either the single row of the query or `null`.
225
+ */
226
+ queryValidatedSingleColumnZeroOrOneRow<Model extends z.ZodTypeAny>(query: string, params: Record<string, any>, model: Model): Promise<z.infer<Model> | null>;
227
+ /**
228
+ * Wrapper around {@link callAsync} that validates that the returned data
229
+ * matches the given validation model. Returns only the rows.
230
+ */
231
+ callValidatedRows<Model extends z.ZodTypeAny>(sprocName: string, params: any[], model: Model): Promise<z.infer<Model>[]>;
232
+ /**
233
+ * Wrapper around {@link callOneRowAsync} that validates that the returned data
234
+ * matches the given validation model. Returns only a single row.
235
+ */
236
+ callValidatedOneRow<Model extends z.ZodTypeAny>(sprocName: string, params: any[], model: Model): Promise<z.infer<Model>>;
237
+ /**
238
+ * Wrapper around {@link callZeroOrOneRowAsync} that validates that the
239
+ * returned data matches the given validation model, if it return anything.
240
+ * Returns at most a single row.
241
+ */
242
+ callValidatedZeroOrOneRow<Model extends z.ZodTypeAny>(sprocName: string, params: any[], model: Model): Promise<z.infer<Model> | null>;
192
243
  /**
193
244
  * Set the schema to use for the search path.
194
245
  *
@@ -213,44 +264,4 @@ export declare class PostgresPool {
213
264
  */
214
265
  setRandomSearchSchema: (arg1: string, callback: (err: NodeJS.ErrnoException, result: string) => void) => void;
215
266
  }
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
267
  export {};
package/dist/pool.js CHANGED
@@ -3,13 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setRandomSearchSchemaAsync = exports.setRandomSearchSchema = exports.getSearchSchema = exports.setSearchSchema = exports.callWithClientZeroOrOneRowAsync = exports.callWithClientZeroOrOneRow = exports.callWithClientOneRowAsync = exports.callWithClientOneRow = exports.callWithClientAsync = exports.callWithClient = exports.callZeroOrOneRowAsync = exports.callZeroOrOneRow = exports.callOneRowAsync = exports.callOneRow = exports.callAsync = exports.call = exports.queryZeroOrOneRowAsync = exports.queryZeroOrOneRow = exports.queryOneRowAsync = exports.queryOneRow = exports.queryAsync = exports.query = exports.runInTransactionAsync = exports.endTransaction = exports.endTransactionAsync = exports.beginTransactionAsync = exports.rollbackWithClient = exports.rollbackWithClientAsync = exports.queryWithClientZeroOrOneRowAsync = exports.queryWithClientZeroOrOneRow = exports.queryWithClientOneRowAsync = exports.queryWithClientOneRow = exports.queryWithClientAsync = exports.queryWithClient = exports.getClient = exports.getClientAsync = exports.closeAsync = exports.close = exports.initAsync = exports.init = exports.PostgresPool = exports.PostgresError = void 0;
6
+ exports.PostgresPool = exports.PostgresError = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const pg_1 = __importDefault(require("pg"));
9
9
  const node_path_1 = __importDefault(require("node:path"));
10
10
  const debug_1 = __importDefault(require("debug"));
11
11
  const node_util_1 = require("node:util");
12
12
  const node_async_hooks_1 = require("node:async_hooks");
13
+ const zod_1 = require("zod");
13
14
  const debug = (0, debug_1.default)('prairielib:' + node_path_1.default.basename(__filename, '.js'));
14
15
  const lastQueryMap = new WeakMap();
15
16
  const searchSchemaMap = new WeakMap();
@@ -458,8 +459,9 @@ class PostgresPool {
458
459
  */
459
460
  async runInTransactionAsync(fn) {
460
461
  const client = await this.beginTransactionAsync();
462
+ let result;
461
463
  try {
462
- await this.alsClient.run(client, () => fn(client));
464
+ result = await this.alsClient.run(client, () => fn(client));
463
465
  }
464
466
  catch (err) {
465
467
  await this.endTransactionAsync(client, err);
@@ -469,6 +471,7 @@ class PostgresPool {
469
471
  // because we don't want an error thrown by it to trigger *another* call
470
472
  // to `endTransactionAsync` in the `catch` block.
471
473
  await this.endTransactionAsync(client, null);
474
+ return result;
472
475
  }
473
476
  /**
474
477
  * Executes a query with the specified parameters.
@@ -613,6 +616,111 @@ class PostgresPool {
613
616
  debug('callWithClientZeroOrOneRow() success', 'rowCount:', result.rowCount);
614
617
  return result;
615
618
  }
619
+ /**
620
+ * Wrapper around {@link queryAsync} that validates that the returned data
621
+ * matches the given validation model. Returns only the rows of the query.
622
+ */
623
+ async queryValidatedRows(query, params, model) {
624
+ const results = await this.queryAsync(query, params);
625
+ return zod_1.z.array(model).parse(results.rows);
626
+ }
627
+ /**
628
+ * Wrapper around {@link queryOneRowAsync} that validates that the returned data
629
+ * matches the given validation model. Returns only a single row of the query.
630
+ */
631
+ async queryValidatedOneRow(query, params, model) {
632
+ const results = await this.queryOneRowAsync(query, params);
633
+ return model.parse(results.rows[0]);
634
+ }
635
+ /**
636
+ * Wrapper around {@link queryZeroOrOneRowAsync} that validates that the
637
+ * returned data matches the given validation model, if it return anything.
638
+ * Returns either the single row of the query or `null`.
639
+ */
640
+ async queryValidatedZeroOrOneRow(query, params, model) {
641
+ const results = await this.queryZeroOrOneRowAsync(query, params);
642
+ if (results.rows.length == 0) {
643
+ return null;
644
+ }
645
+ else {
646
+ return model.parse(results.rows[0]);
647
+ }
648
+ }
649
+ /**
650
+ * Wrapper around {@link queryAsync} that validates that only one column is
651
+ * returned and the data in it matches the given validation model. Returns only
652
+ * the single column of the query as an array.
653
+ */
654
+ async queryValidatedSingleColumnRows(query, params, model) {
655
+ const results = await this.queryAsync(query, params);
656
+ if (results.fields.length != 1) {
657
+ throw new Error(`Expected one column, got ${results.fields.length}`);
658
+ }
659
+ const columnName = results.fields[0].name;
660
+ const rawData = results.rows.map((row) => row[columnName]);
661
+ return zod_1.z.array(model).parse(rawData);
662
+ }
663
+ /**
664
+ * Wrapper around {@link queryOneRowAsync} that validates that only one column
665
+ * is returned and the data in it matches the given validation model. Returns
666
+ * only the single entry.
667
+ */
668
+ async queryValidatedSingleColumnOneRow(query, params, model) {
669
+ const results = await this.queryOneRowAsync(query, params);
670
+ if (results.fields.length != 1) {
671
+ throw new Error(`Expected one column, got ${results.fields.length}`);
672
+ }
673
+ const columnName = results.fields[0].name;
674
+ return model.parse(results.rows[0][columnName]);
675
+ }
676
+ /**
677
+ * Wrapper around {@link queryZeroOrOneRowAsync} that validates that only one
678
+ * column is returned and the data in it matches the given validation model, if
679
+ * it return anything. Returns either the single row of the query or `null`.
680
+ */
681
+ async queryValidatedSingleColumnZeroOrOneRow(query, params, model) {
682
+ const results = await this.queryZeroOrOneRowAsync(query, params);
683
+ if (results.fields.length != 1) {
684
+ throw new Error(`Expected one column, got ${results.fields.length}`);
685
+ }
686
+ if (results.rows.length == 0) {
687
+ return null;
688
+ }
689
+ else {
690
+ const columnName = results.fields[0].name;
691
+ return model.parse(results.rows[0][columnName]);
692
+ }
693
+ }
694
+ /**
695
+ * Wrapper around {@link callAsync} that validates that the returned data
696
+ * matches the given validation model. Returns only the rows.
697
+ */
698
+ async callValidatedRows(sprocName, params, model) {
699
+ const results = await this.callAsync(sprocName, params);
700
+ return zod_1.z.array(model).parse(results.rows);
701
+ }
702
+ /**
703
+ * Wrapper around {@link callOneRowAsync} that validates that the returned data
704
+ * matches the given validation model. Returns only a single row.
705
+ */
706
+ async callValidatedOneRow(sprocName, params, model) {
707
+ const results = await this.callOneRowAsync(sprocName, params);
708
+ return model.parse(results.rows[0]);
709
+ }
710
+ /**
711
+ * Wrapper around {@link callZeroOrOneRowAsync} that validates that the
712
+ * returned data matches the given validation model, if it return anything.
713
+ * Returns at most a single row.
714
+ */
715
+ async callValidatedZeroOrOneRow(sprocName, params, model) {
716
+ const results = await this.callZeroOrOneRowAsync(sprocName, params);
717
+ if (results.rows.length == 0) {
718
+ return null;
719
+ }
720
+ else {
721
+ return model.parse(results.rows[0]);
722
+ }
723
+ }
616
724
  /**
617
725
  * Set the schema to use for the search path.
618
726
  *
@@ -660,53 +768,4 @@ class PostgresPool {
660
768
  }
661
769
  }
662
770
  exports.PostgresPool = PostgresPool;
663
- const defaultPool = new PostgresPool();
664
- // We re-expose all functions from the default pool here to account for the
665
- // default case of a shared global pool of clients. If someone want to create
666
- // their own pool, we expose the `PostgresPool` class.
667
- //
668
- // Note that we explicitly bind all functions to `defaultPool`. This ensures
669
- // that they'll be invoked with the correct `this` context, specifically when
670
- // this module is imported as `import * as db from '...'` and that import is
671
- // subsequently transformed by Babel to `interopRequireWildcard(...)`.
672
- exports.init = defaultPool.init.bind(defaultPool);
673
- exports.initAsync = defaultPool.initAsync.bind(defaultPool);
674
- exports.close = defaultPool.close.bind(defaultPool);
675
- exports.closeAsync = defaultPool.closeAsync.bind(defaultPool);
676
- exports.getClientAsync = defaultPool.getClientAsync.bind(defaultPool);
677
- exports.getClient = defaultPool.getClient.bind(defaultPool);
678
- exports.queryWithClient = defaultPool.queryWithClient.bind(defaultPool);
679
- exports.queryWithClientAsync = defaultPool.queryWithClientAsync.bind(defaultPool);
680
- exports.queryWithClientOneRow = defaultPool.queryWithClientOneRow.bind(defaultPool);
681
- exports.queryWithClientOneRowAsync = defaultPool.queryWithClientOneRowAsync.bind(defaultPool);
682
- exports.queryWithClientZeroOrOneRow = defaultPool.queryWithClientZeroOrOneRow.bind(defaultPool);
683
- exports.queryWithClientZeroOrOneRowAsync = defaultPool.queryWithClientZeroOrOneRowAsync.bind(defaultPool);
684
- exports.rollbackWithClientAsync = defaultPool.rollbackWithClientAsync.bind(defaultPool);
685
- exports.rollbackWithClient = defaultPool.rollbackWithClient.bind(defaultPool);
686
- exports.beginTransactionAsync = defaultPool.beginTransactionAsync.bind(defaultPool);
687
- exports.endTransactionAsync = defaultPool.endTransactionAsync.bind(defaultPool);
688
- exports.endTransaction = defaultPool.endTransaction.bind(defaultPool);
689
- exports.runInTransactionAsync = defaultPool.runInTransactionAsync.bind(defaultPool);
690
- exports.query = defaultPool.query.bind(defaultPool);
691
- exports.queryAsync = defaultPool.queryAsync.bind(defaultPool);
692
- exports.queryOneRow = defaultPool.queryOneRow.bind(defaultPool);
693
- exports.queryOneRowAsync = defaultPool.queryOneRowAsync.bind(defaultPool);
694
- exports.queryZeroOrOneRow = defaultPool.queryZeroOrOneRow.bind(defaultPool);
695
- exports.queryZeroOrOneRowAsync = defaultPool.queryZeroOrOneRowAsync.bind(defaultPool);
696
- exports.call = defaultPool.call.bind(defaultPool);
697
- exports.callAsync = defaultPool.callAsync.bind(defaultPool);
698
- exports.callOneRow = defaultPool.callOneRow.bind(defaultPool);
699
- exports.callOneRowAsync = defaultPool.callOneRowAsync.bind(defaultPool);
700
- exports.callZeroOrOneRow = defaultPool.callZeroOrOneRow.bind(defaultPool);
701
- exports.callZeroOrOneRowAsync = defaultPool.callZeroOrOneRowAsync.bind(defaultPool);
702
- exports.callWithClient = defaultPool.callWithClient.bind(defaultPool);
703
- exports.callWithClientAsync = defaultPool.callWithClientAsync.bind(defaultPool);
704
- exports.callWithClientOneRow = defaultPool.callWithClientOneRow.bind(defaultPool);
705
- exports.callWithClientOneRowAsync = defaultPool.callWithClientOneRowAsync.bind(defaultPool);
706
- exports.callWithClientZeroOrOneRow = defaultPool.callWithClientZeroOrOneRow.bind(defaultPool);
707
- exports.callWithClientZeroOrOneRowAsync = defaultPool.callWithClientZeroOrOneRowAsync.bind(defaultPool);
708
- exports.setSearchSchema = defaultPool.setSearchSchema.bind(defaultPool);
709
- exports.getSearchSchema = defaultPool.getSearchSchema.bind(defaultPool);
710
- exports.setRandomSearchSchema = defaultPool.setRandomSearchSchema.bind(defaultPool);
711
- exports.setRandomSearchSchemaAsync = defaultPool.setRandomSearchSchemaAsync.bind(defaultPool);
712
771
  //# sourceMappingURL=pool.js.map
package/dist/pool.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pool.js","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,4CAAqC;AACrC,0DAA6B;AAC7B,kDAAiC;AACjC,yCAAwC;AACxC,uDAAqD;AAIrD,MAAM,KAAK,GAAG,IAAA,eAAY,EAAC,aAAa,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;AAC7E,MAAM,YAAY,GAAmC,IAAI,OAAO,EAAE,CAAC;AACnE,MAAM,eAAe,GAAmC,IAAI,OAAO,EAAE,CAAC;AAEtE,SAAS,cAAc,CAAC,GAAU,EAAE,IAAyB;IAC1D,GAAW,CAAC,IAAI,GAAG;QAClB,GAAG,CAAE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AO;SACR;QAED,MAAM,IAAI,CAAC,UAAU,CAAC,+BAA+B,gBAAgB,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACrF,4FAA4F;QAC5F,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,0BAA0B,CAAC,MAAc;QAC7C,uCAAuC;QACvC,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5C,oGAAoG;QACpG,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC3C,gFAAgF;QAChF,MAAM,KAAK,GAAG,sCAAsC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/D,MAAM,MAAM,GAAG,gBAAC,CAAC,KAAK,CAAC,CAAC,EAAE;YACxB,OAAO,gBAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEZ,0EAA0E;QAC1E,oDAAoD;QACpD,wFAAwF;QACxF,MAAM,MAAM,GAAG,GAAG,WAAW,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;QACvD,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACnC,OAAO,MAAM,CAAC;IAChB,CAAC;CAMF;AAhwBD,oCAgwBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prairielearn/postgres",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "main": "./dist/index.js",
5
5
  "scripts": {
6
6
  "build": "tsc",
@@ -17,6 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@types/debug": "^4.1.7",
20
- "@types/lodash": "^4.14.191"
20
+ "@types/lodash": "^4.14.191",
21
+ "zod": "^3.20.2"
21
22
  }
22
23
  }
@@ -1,5 +1,6 @@
1
1
  import { assert } from 'chai';
2
- import * as pgPool from './pool';
2
+ import { PostgresPool } from './pool';
3
+ import * as pgPool from './default-pool';
3
4
 
4
5
  /**
5
6
  * Returns true if the property on `PostgresPool` should be considered
@@ -18,7 +19,7 @@ function isHiddenProperty(property: string) {
18
19
 
19
20
  describe('sqldb', () => {
20
21
  it('exports the full PostgresPool interface', () => {
21
- const pool = new pgPool.PostgresPool();
22
+ const pool = new PostgresPool();
22
23
 
23
24
  Object.getOwnPropertyNames(pool)
24
25
  .filter((n) => !isHiddenProperty(n))
@@ -34,7 +35,7 @@ describe('sqldb', () => {
34
35
  });
35
36
 
36
37
  it('should not have extra properties', () => {
37
- const pool = new pgPool.PostgresPool();
38
+ const pool = new PostgresPool();
38
39
 
39
40
  const knownProperties = [
40
41
  ...Object.getOwnPropertyNames(pool),
@@ -0,0 +1,67 @@
1
+ import { PostgresPool } from './pool';
2
+
3
+ const defaultPool = new PostgresPool();
4
+
5
+ // We re-expose all functions from the default pool here to account for the
6
+ // default case of a shared global pool of clients. If someone want to create
7
+ // their own pool, we expose the `PostgresPool` class.
8
+ //
9
+ // Note that we explicitly bind all functions to `defaultPool`. This ensures
10
+ // that they'll be invoked with the correct `this` context, specifically when
11
+ // this module is imported as `import * as db from '...'` and that import is
12
+ // subsequently transformed by Babel to `interopRequireWildcard(...)`.
13
+ export const init = defaultPool.init.bind(defaultPool);
14
+ export const initAsync = defaultPool.initAsync.bind(defaultPool);
15
+ export const close = defaultPool.close.bind(defaultPool);
16
+ export const closeAsync = defaultPool.closeAsync.bind(defaultPool);
17
+ export const getClientAsync = defaultPool.getClientAsync.bind(defaultPool);
18
+ export const getClient = defaultPool.getClient.bind(defaultPool);
19
+ export const queryWithClient = defaultPool.queryWithClient.bind(defaultPool);
20
+ export const queryWithClientAsync = defaultPool.queryWithClientAsync.bind(defaultPool);
21
+ export const queryWithClientOneRow = defaultPool.queryWithClientOneRow.bind(defaultPool);
22
+ export const queryWithClientOneRowAsync = defaultPool.queryWithClientOneRowAsync.bind(defaultPool);
23
+ export const queryWithClientZeroOrOneRow =
24
+ defaultPool.queryWithClientZeroOrOneRow.bind(defaultPool);
25
+ export const queryWithClientZeroOrOneRowAsync =
26
+ defaultPool.queryWithClientZeroOrOneRowAsync.bind(defaultPool);
27
+ export const rollbackWithClientAsync = defaultPool.rollbackWithClientAsync.bind(defaultPool);
28
+ export const rollbackWithClient = defaultPool.rollbackWithClient.bind(defaultPool);
29
+ export const beginTransactionAsync = defaultPool.beginTransactionAsync.bind(defaultPool);
30
+ export const endTransactionAsync = defaultPool.endTransactionAsync.bind(defaultPool);
31
+ export const endTransaction = defaultPool.endTransaction.bind(defaultPool);
32
+ export const runInTransactionAsync = defaultPool.runInTransactionAsync.bind(defaultPool);
33
+ export const query = defaultPool.query.bind(defaultPool);
34
+ export const queryAsync = defaultPool.queryAsync.bind(defaultPool);
35
+ export const queryOneRow = defaultPool.queryOneRow.bind(defaultPool);
36
+ export const queryOneRowAsync = defaultPool.queryOneRowAsync.bind(defaultPool);
37
+ export const queryZeroOrOneRow = defaultPool.queryZeroOrOneRow.bind(defaultPool);
38
+ export const queryZeroOrOneRowAsync = defaultPool.queryZeroOrOneRowAsync.bind(defaultPool);
39
+ export const call = defaultPool.call.bind(defaultPool);
40
+ export const callAsync = defaultPool.callAsync.bind(defaultPool);
41
+ export const callOneRow = defaultPool.callOneRow.bind(defaultPool);
42
+ export const callOneRowAsync = defaultPool.callOneRowAsync.bind(defaultPool);
43
+ export const callZeroOrOneRow = defaultPool.callZeroOrOneRow.bind(defaultPool);
44
+ export const callZeroOrOneRowAsync = defaultPool.callZeroOrOneRowAsync.bind(defaultPool);
45
+ export const callWithClient = defaultPool.callWithClient.bind(defaultPool);
46
+ export const callWithClientAsync = defaultPool.callWithClientAsync.bind(defaultPool);
47
+ export const callWithClientOneRow = defaultPool.callWithClientOneRow.bind(defaultPool);
48
+ export const callWithClientOneRowAsync = defaultPool.callWithClientOneRowAsync.bind(defaultPool);
49
+ export const callWithClientZeroOrOneRow = defaultPool.callWithClientZeroOrOneRow.bind(defaultPool);
50
+ export const callWithClientZeroOrOneRowAsync =
51
+ defaultPool.callWithClientZeroOrOneRowAsync.bind(defaultPool);
52
+ export const queryValidatedRows = defaultPool.queryValidatedRows.bind(defaultPool);
53
+ export const queryValidatedOneRow = defaultPool.queryValidatedOneRow.bind(defaultPool);
54
+ export const queryValidatedZeroOrOneRow = defaultPool.queryValidatedZeroOrOneRow.bind(defaultPool);
55
+ export const queryValidatedSingleColumnRows =
56
+ defaultPool.queryValidatedSingleColumnRows.bind(defaultPool);
57
+ export const queryValidatedSingleColumnOneRow =
58
+ defaultPool.queryValidatedSingleColumnOneRow.bind(defaultPool);
59
+ export const queryValidatedSingleColumnZeroOrOneRow =
60
+ defaultPool.queryValidatedSingleColumnZeroOrOneRow.bind(defaultPool);
61
+ export const callValidatedRows = defaultPool.callValidatedRows.bind(defaultPool);
62
+ export const callValidatedOneRow = defaultPool.callValidatedOneRow.bind(defaultPool);
63
+ export const callValidatedZeroOrOneRow = defaultPool.callValidatedZeroOrOneRow.bind(defaultPool);
64
+ export const setSearchSchema = defaultPool.setSearchSchema.bind(defaultPool);
65
+ export const getSearchSchema = defaultPool.getSearchSchema.bind(defaultPool);
66
+ export const setRandomSearchSchema = defaultPool.setRandomSearchSchema.bind(defaultPool);
67
+ export const setRandomSearchSchemaAsync = defaultPool.setRandomSearchSchemaAsync.bind(defaultPool);
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
- export { loadSql, loadSqlEquiv } from './loader';
2
- export * from './pool';
3
1
  export { PoolClient } from 'pg';
2
+
3
+ export { loadSql, loadSqlEquiv } from './loader';
4
+ export { PostgresPool } from './pool';
5
+ export * from './default-pool';
package/src/pool.ts CHANGED
@@ -4,6 +4,7 @@ import path from 'node:path';
4
4
  import debugFactory from 'debug';
5
5
  import { callbackify } from 'node:util';
6
6
  import { AsyncLocalStorage } from 'node:async_hooks';
7
+ import { z } from 'zod';
7
8
 
8
9
  type Params = Record<string, any> | any[];
9
10
 
@@ -448,10 +449,11 @@ export class PostgresPool {
448
449
  * The transaction will be rolled back if the function throws an error, and
449
450
  * will be committed otherwise.
450
451
  */
451
- async runInTransactionAsync(fn: (client: pg.PoolClient) => Promise<void>): Promise<void> {
452
+ async runInTransactionAsync<T>(fn: (client: pg.PoolClient) => Promise<T>): Promise<T> {
452
453
  const client = await this.beginTransactionAsync();
454
+ let result: T;
453
455
  try {
454
- await this.alsClient.run(client, () => fn(client));
456
+ result = await this.alsClient.run(client, () => fn(client));
455
457
  } catch (err: any) {
456
458
  await this.endTransactionAsync(client, err);
457
459
  throw err;
@@ -461,6 +463,8 @@ export class PostgresPool {
461
463
  // because we don't want an error thrown by it to trigger *another* call
462
464
  // to `endTransactionAsync` in the `catch` block.
463
465
  await this.endTransactionAsync(client, null);
466
+
467
+ return result;
464
468
  }
465
469
 
466
470
  /**
@@ -677,6 +681,153 @@ export class PostgresPool {
677
681
  */
678
682
  callWithClientZeroOrOneRow = callbackify(this.callWithClientZeroOrOneRowAsync);
679
683
 
684
+ /**
685
+ * Wrapper around {@link queryAsync} that validates that the returned data
686
+ * matches the given validation model. Returns only the rows of the query.
687
+ */
688
+ async queryValidatedRows<Model extends z.ZodTypeAny>(
689
+ query: string,
690
+ params: Record<string, any>,
691
+ model: Model
692
+ ): Promise<z.infer<Model>[]> {
693
+ const results = await this.queryAsync(query, params);
694
+ return z.array(model).parse(results.rows);
695
+ }
696
+
697
+ /**
698
+ * Wrapper around {@link queryOneRowAsync} that validates that the returned data
699
+ * matches the given validation model. Returns only a single row of the query.
700
+ */
701
+ async queryValidatedOneRow<Model extends z.ZodTypeAny>(
702
+ query: string,
703
+ params: Record<string, any>,
704
+ model: Model
705
+ ): Promise<z.infer<Model>> {
706
+ const results = await this.queryOneRowAsync(query, params);
707
+ return model.parse(results.rows[0]);
708
+ }
709
+
710
+ /**
711
+ * Wrapper around {@link queryZeroOrOneRowAsync} that validates that the
712
+ * returned data matches the given validation model, if it return anything.
713
+ * Returns either the single row of the query or `null`.
714
+ */
715
+ async queryValidatedZeroOrOneRow<Model extends z.ZodTypeAny>(
716
+ query: string,
717
+ params: Record<string, any>,
718
+ model: Model
719
+ ): Promise<z.infer<Model> | null> {
720
+ const results = await this.queryZeroOrOneRowAsync(query, params);
721
+ if (results.rows.length == 0) {
722
+ return null;
723
+ } else {
724
+ return model.parse(results.rows[0]);
725
+ }
726
+ }
727
+
728
+ /**
729
+ * Wrapper around {@link queryAsync} that validates that only one column is
730
+ * returned and the data in it matches the given validation model. Returns only
731
+ * the single column of the query as an array.
732
+ */
733
+ async queryValidatedSingleColumnRows<Model extends z.ZodTypeAny>(
734
+ query: string,
735
+ params: Record<string, any>,
736
+ model: Model
737
+ ): Promise<z.infer<Model>[]> {
738
+ const results = await this.queryAsync(query, params);
739
+ if (results.fields.length != 1) {
740
+ throw new Error(`Expected one column, got ${results.fields.length}`);
741
+ }
742
+ const columnName = results.fields[0].name;
743
+ const rawData = results.rows.map((row) => row[columnName]);
744
+ return z.array(model).parse(rawData);
745
+ }
746
+
747
+ /**
748
+ * Wrapper around {@link queryOneRowAsync} that validates that only one column
749
+ * is returned and the data in it matches the given validation model. Returns
750
+ * only the single entry.
751
+ */
752
+ async queryValidatedSingleColumnOneRow<Model extends z.ZodTypeAny>(
753
+ query: string,
754
+ params: Record<string, any>,
755
+ model: Model
756
+ ): Promise<z.infer<Model>> {
757
+ const results = await this.queryOneRowAsync(query, params);
758
+ if (results.fields.length != 1) {
759
+ throw new Error(`Expected one column, got ${results.fields.length}`);
760
+ }
761
+ const columnName = results.fields[0].name;
762
+ return model.parse(results.rows[0][columnName]);
763
+ }
764
+
765
+ /**
766
+ * Wrapper around {@link queryZeroOrOneRowAsync} that validates that only one
767
+ * column is returned and the data in it matches the given validation model, if
768
+ * it return anything. Returns either the single row of the query or `null`.
769
+ */
770
+ async queryValidatedSingleColumnZeroOrOneRow<Model extends z.ZodTypeAny>(
771
+ query: string,
772
+ params: Record<string, any>,
773
+ model: Model
774
+ ): Promise<z.infer<Model> | null> {
775
+ const results = await this.queryZeroOrOneRowAsync(query, params);
776
+ if (results.fields.length != 1) {
777
+ throw new Error(`Expected one column, got ${results.fields.length}`);
778
+ }
779
+ if (results.rows.length == 0) {
780
+ return null;
781
+ } else {
782
+ const columnName = results.fields[0].name;
783
+ return model.parse(results.rows[0][columnName]);
784
+ }
785
+ }
786
+
787
+ /**
788
+ * Wrapper around {@link callAsync} that validates that the returned data
789
+ * matches the given validation model. Returns only the rows.
790
+ */
791
+ async callValidatedRows<Model extends z.ZodTypeAny>(
792
+ sprocName: string,
793
+ params: any[],
794
+ model: Model
795
+ ): Promise<z.infer<Model>[]> {
796
+ const results = await this.callAsync(sprocName, params);
797
+ return z.array(model).parse(results.rows);
798
+ }
799
+
800
+ /**
801
+ * Wrapper around {@link callOneRowAsync} that validates that the returned data
802
+ * matches the given validation model. Returns only a single row.
803
+ */
804
+ async callValidatedOneRow<Model extends z.ZodTypeAny>(
805
+ sprocName: string,
806
+ params: any[],
807
+ model: Model
808
+ ): Promise<z.infer<Model>> {
809
+ const results = await this.callOneRowAsync(sprocName, params);
810
+ return model.parse(results.rows[0]);
811
+ }
812
+
813
+ /**
814
+ * Wrapper around {@link callZeroOrOneRowAsync} that validates that the
815
+ * returned data matches the given validation model, if it return anything.
816
+ * Returns at most a single row.
817
+ */
818
+ async callValidatedZeroOrOneRow<Model extends z.ZodTypeAny>(
819
+ sprocName: string,
820
+ params: any[],
821
+ model: Model
822
+ ): Promise<z.infer<Model> | null> {
823
+ const results = await this.callZeroOrOneRowAsync(sprocName, params);
824
+ if (results.rows.length == 0) {
825
+ return null;
826
+ } else {
827
+ return model.parse(results.rows[0]);
828
+ }
829
+ }
830
+
680
831
  /**
681
832
  * Set the schema to use for the search path.
682
833
  *
@@ -732,57 +883,3 @@ export class PostgresPool {
732
883
  */
733
884
  setRandomSearchSchema = callbackify(this.setRandomSearchSchemaAsync);
734
885
  }
735
-
736
- const defaultPool = new PostgresPool();
737
-
738
- // We re-expose all functions from the default pool here to account for the
739
- // default case of a shared global pool of clients. If someone want to create
740
- // their own pool, we expose the `PostgresPool` class.
741
- //
742
- // Note that we explicitly bind all functions to `defaultPool`. This ensures
743
- // that they'll be invoked with the correct `this` context, specifically when
744
- // this module is imported as `import * as db from '...'` and that import is
745
- // subsequently transformed by Babel to `interopRequireWildcard(...)`.
746
- export const init = defaultPool.init.bind(defaultPool);
747
- export const initAsync = defaultPool.initAsync.bind(defaultPool);
748
- export const close = defaultPool.close.bind(defaultPool);
749
- export const closeAsync = defaultPool.closeAsync.bind(defaultPool);
750
- export const getClientAsync = defaultPool.getClientAsync.bind(defaultPool);
751
- export const getClient = defaultPool.getClient.bind(defaultPool);
752
- export const queryWithClient = defaultPool.queryWithClient.bind(defaultPool);
753
- export const queryWithClientAsync = defaultPool.queryWithClientAsync.bind(defaultPool);
754
- export const queryWithClientOneRow = defaultPool.queryWithClientOneRow.bind(defaultPool);
755
- export const queryWithClientOneRowAsync = defaultPool.queryWithClientOneRowAsync.bind(defaultPool);
756
- export const queryWithClientZeroOrOneRow =
757
- defaultPool.queryWithClientZeroOrOneRow.bind(defaultPool);
758
- export const queryWithClientZeroOrOneRowAsync =
759
- defaultPool.queryWithClientZeroOrOneRowAsync.bind(defaultPool);
760
- export const rollbackWithClientAsync = defaultPool.rollbackWithClientAsync.bind(defaultPool);
761
- export const rollbackWithClient = defaultPool.rollbackWithClient.bind(defaultPool);
762
- export const beginTransactionAsync = defaultPool.beginTransactionAsync.bind(defaultPool);
763
- export const endTransactionAsync = defaultPool.endTransactionAsync.bind(defaultPool);
764
- export const endTransaction = defaultPool.endTransaction.bind(defaultPool);
765
- export const runInTransactionAsync = defaultPool.runInTransactionAsync.bind(defaultPool);
766
- export const query = defaultPool.query.bind(defaultPool);
767
- export const queryAsync = defaultPool.queryAsync.bind(defaultPool);
768
- export const queryOneRow = defaultPool.queryOneRow.bind(defaultPool);
769
- export const queryOneRowAsync = defaultPool.queryOneRowAsync.bind(defaultPool);
770
- export const queryZeroOrOneRow = defaultPool.queryZeroOrOneRow.bind(defaultPool);
771
- export const queryZeroOrOneRowAsync = defaultPool.queryZeroOrOneRowAsync.bind(defaultPool);
772
- export const call = defaultPool.call.bind(defaultPool);
773
- export const callAsync = defaultPool.callAsync.bind(defaultPool);
774
- export const callOneRow = defaultPool.callOneRow.bind(defaultPool);
775
- export const callOneRowAsync = defaultPool.callOneRowAsync.bind(defaultPool);
776
- export const callZeroOrOneRow = defaultPool.callZeroOrOneRow.bind(defaultPool);
777
- export const callZeroOrOneRowAsync = defaultPool.callZeroOrOneRowAsync.bind(defaultPool);
778
- export const callWithClient = defaultPool.callWithClient.bind(defaultPool);
779
- export const callWithClientAsync = defaultPool.callWithClientAsync.bind(defaultPool);
780
- export const callWithClientOneRow = defaultPool.callWithClientOneRow.bind(defaultPool);
781
- export const callWithClientOneRowAsync = defaultPool.callWithClientOneRowAsync.bind(defaultPool);
782
- export const callWithClientZeroOrOneRow = defaultPool.callWithClientZeroOrOneRow.bind(defaultPool);
783
- export const callWithClientZeroOrOneRowAsync =
784
- defaultPool.callWithClientZeroOrOneRowAsync.bind(defaultPool);
785
- export const setSearchSchema = defaultPool.setSearchSchema.bind(defaultPool);
786
- export const getSearchSchema = defaultPool.getSearchSchema.bind(defaultPool);
787
- export const setRandomSearchSchema = defaultPool.setRandomSearchSchema.bind(defaultPool);
788
- export const setRandomSearchSchemaAsync = defaultPool.setRandomSearchSchemaAsync.bind(defaultPool);
@@ -1 +0,0 @@
1
- {"version":3,"file":"pool.test.js","sourceRoot":"","sources":["../src/pool.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,+CAAiC;AAEjC;;;GAGG;AACH,SAAS,gBAAgB,CAAC,QAAgB;IACxC,QAAQ,QAAQ,EAAE;QAChB,KAAK,MAAM,CAAC;QAC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