import { PostgreSQLAdapter } from "../base.js"; import type { Controller, TableNames } from "../base.js"; import type { Sql } from "postgres"; export class PostgresJsAdapter extends PostgreSQLAdapter { constructor(sql: Sql, tableNames: TableNames) { super(new PostgresJsController(sql), tableNames); } } class PostgresJsController implements Controller { private sql: Sql; constructor(sql: Sql) { this.sql = sql; } public async get(sql: string, args: any[]): Promise { const result: T[] = await this.sql.unsafe(sql, args); return result.at(0) ?? null; } public async getAll(sql: string, args: any[]): Promise { const result: T[] = await this.sql.unsafe(sql, args); return result; } public async execute(sql: string, args: any[]): Promise { await this.sql.unsafe(sql, args); } }