From ee3dbd3b6ac14512e799c9c6b7e99c6773e9762d Mon Sep 17 00:00:00 2001 From: Wang Zuo Date: Sun, 28 Jan 2024 10:52:59 +0800 Subject: [PATCH] fix pg module import (#84) --- .../templates/queryx/adapter.postgresql.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/generator/client/typescript/templates/queryx/adapter.postgresql.ts b/generator/client/typescript/templates/queryx/adapter.postgresql.ts index d6010b8..3030fac 100644 --- a/generator/client/typescript/templates/queryx/adapter.postgresql.ts +++ b/generator/client/typescript/templates/queryx/adapter.postgresql.ts @@ -1,22 +1,22 @@ // Code generated by queryx, DO NOT EDIT. -import { Pool, QueryResultRow, types } from "pg"; +import pg from "pg"; import { parse } from "date-fns"; import { Config } from "./config"; -types.setTypeParser(types.builtins.INT8, (val) => parseInt(val, 10)); +pg.types.setTypeParser(pg.types.builtins.INT8, (val) => parseInt(val, 10)); export class Adapter { public config: Config; - public pool: Pool; - public db: Pool; + public pool?: pg.Pool; + public db?: pg.Pool; constructor(config: Config) { this.config = config; } connect() { - const pool = new Pool({ + const pool = new pg.Pool({ connectionString: this.config.url, }); this.pool = pool; @@ -31,7 +31,7 @@ export class Adapter { this.db.release(); } - private _query( + private _query( query: string, args?: I, ) { @@ -39,12 +39,15 @@ export class Adapter { return this.db.query(query1, args1); } - async query(query: string, ...args: any[]) { + async query( + query: string, + ...args: any[] + ) { const res = await this._query(query, args); return res.rows; } - async queryOne( + async queryOne( query: string, ...args: any[] ) {