import {QueryResult} from './types.ts' /** * Error thrown when a connection is used before it is ready. * @extends Error */ export class ConnectionNotReadyError extends Error { constructor(name = '') { super(`The connection ${name} is not ready and cannot execute queries.`) } } /** * Abstract base class for database connections. * @abstract */ export abstract class Connection { constructor( /** * The name of this connection * @type string */ public readonly name: string, /** * This connection's config object */ public readonly config: any = {}, ) {} /** * Open the connection. * @return Promise */ public abstract async init(): Promise /** * Execute an SQL query and get the result. * @param {string} query * @return Promise */ public abstract async query(query: string): Promise // TODO query result /** * Close the connection. * @return Promise */ public abstract async close(): Promise }