import { SQLiteAdapter } from "../base.js"; import type { Controller, TableNames } from "../base.js"; import type { Database } from "better-sqlite3"; export class BetterSqlite3Adapter extends SQLiteAdapter { constructor(db: Database, tableNames: TableNames) { super(new BetterSqlite3Controller(db), tableNames); } } class BetterSqlite3Controller implements Controller { private db: Database; constructor(db: Database) { this.db = db; } public async get(sql: string, args: any[]): Promise { return this.db.prepare(sql).get(...args); } public async getAll(sql: string, args: any[]): Promise { return this.db.prepare(sql).all(...args); } public async execute(sql: string, args: any[]): Promise { await this.db.prepare(sql).run(...args); } }