import { QueryBuilder } from "../querybuilder.ts" ; import type { DatabaseDialect } from "../connect.ts" ; import { Manager } from "../manager.ts" ; /**
 * Database connection options
 */ export interface ConnectionOptions { database ? : string ; username ? : string ; port ? : number ; hostname ? : string ; password ? : string ; applicationName ? : string ; } export type DatabaseValues = string | number | Date | boolean | null | undefined ; export interface DatabaseResult { [ key ] : DatabaseValues ; } /**
 * The parent class for all database adapters
 */ export abstract class Adapter { public abstract dialect : DatabaseDialect ; public abstract lastInsertedId : number ; param query param values public abstract query ( query , values ? ) ; /**
     * Connect database
     */ public abstract connect ( ) ; /**
     * Disconnect database
     */ public abstract disconnect ( ) ; param tableName public table ( tableName ) { return new QueryBuilder ( tableName , this ) ; } /**
     * Get the model manager
     */ public getManager ( ) { return new Manager ( this ) ; } /**
     * Start a database transaction.
     */ async transaction ( fn ) { const query = this . dialect === "sqlite" ? "BEGIN TRANSACTION;" : "START TRANSACTION;" ; await this . query ( query ) ; try { await fn ( ) ; await this . query ( "COMMIT;" ) ; } catch ( err ) { await this . query ( "ROLLBACK;" ) ; throw err ; } } }