Skip to content

Commit ee3dbd3

Browse files
authored
fix pg module import (#84)
1 parent 10a41b9 commit ee3dbd3

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

generator/client/typescript/templates/queryx/adapter.postgresql.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// Code generated by queryx, DO NOT EDIT.
22

3-
import { Pool, QueryResultRow, types } from "pg";
3+
import pg from "pg";
44
import { parse } from "date-fns";
55
import { Config } from "./config";
66

7-
types.setTypeParser(types.builtins.INT8, (val) => parseInt(val, 10));
7+
pg.types.setTypeParser(pg.types.builtins.INT8, (val) => parseInt(val, 10));
88

99
export class Adapter {
1010
public config: Config;
11-
public pool: Pool;
12-
public db: Pool;
11+
public pool?: pg.Pool;
12+
public db?: pg.Pool;
1313

1414
constructor(config: Config) {
1515
this.config = config;
1616
}
1717

1818
connect() {
19-
const pool = new Pool({
19+
const pool = new pg.Pool({
2020
connectionString: this.config.url,
2121
});
2222
this.pool = pool;
@@ -31,20 +31,23 @@ export class Adapter {
3131
this.db.release();
3232
}
3333

34-
private _query<R extends QueryResultRow = any, I extends any[] = any[]>(
34+
private _query<R extends pg.QueryResultRow = any, I extends any[] = any[]>(
3535
query: string,
3636
args?: I,
3737
) {
3838
let [query1, args1] = rebind<I>(query, args);
3939
return this.db.query<R, I>(query1, args1);
4040
}
4141

42-
async query<R extends QueryResultRow = any>(query: string, ...args: any[]) {
42+
async query<R extends pg.QueryResultRow = any>(
43+
query: string,
44+
...args: any[]
45+
) {
4346
const res = await this._query<R>(query, args);
4447
return res.rows;
4548
}
4649

47-
async queryOne<R extends QueryResultRow = any>(
50+
async queryOne<R extends pg.QueryResultRow = any>(
4851
query: string,
4952
...args: any[]
5053
) {

0 commit comments

Comments
 (0)