import { PostgresClient } from "../../deps.ts" ; import { Adapter , ConnectionOptions , DatabaseResult } from "./adapter.ts" ; import type { DatabaseDialect } from "../connect.ts" ; /**
 * PostgreSQL database adapter
 */ export class PostgresAdapter extends Adapter { public dialect : DatabaseDialect = "postgres" ; public lastInsertedId = 0 ; /**
     * Postgres client
     */ private client : PostgresClient ; constructor ( options ) { super ( ) ; this . client = new PostgresClient ( { database : options . database , port : options . port , hostname : options . hostname , password : options . password , user : options . username , applicationName : options . applicationName } ) ; } public connect ( ) { return this . client . connect ( ) ; } public disconnect ( ) { return this . client . end ( ) ; } public async query ( query , values ? ) { let result = Array . isArray ( values ) && values . length >= 1 ? await this . client . query ( { text : query , args : values } ) : await this . client . query ( query ) ; return result . rowsOfObjects ( ) ; } }