import { ArrayItemType } from '../util/type-utils.js'; import { DatabaseConnection } from './database-connection.js'; /** * A Driver creates and releases {@link DatabaseConnection | database connections} * and is also responsible for connection pooling (if the dialect supports pooling). */ export interface Driver { /** * Initializes the driver. * * After calling this method the driver should be usable and `acquireConnection` etc. * methods should be callable. */ init(): Promise; /** * Acquires a new connection from the pool. */ acquireConnection(): Promise; /** * Begins a transaction. */ beginTransaction(connection: DatabaseConnection, settings: TransactionSettings): Promise; /** * Commits a transaction. */ commitTransaction(connection: DatabaseConnection): Promise; /** * Rolls back a transaction. */ rollbackTransaction(connection: DatabaseConnection): Promise; /** * Releases a connection back to the pool. */ releaseConnection(connection: DatabaseConnection): Promise; /** * Destroys the driver and releases all resources. */ destroy(): Promise; } export interface TransactionSettings { readonly isolationLevel?: IsolationLevel; } export declare const TRANSACTION_ISOLATION_LEVELS: readonly ["read uncommitted", "read committed", "repeatable read", "serializable", "snapshot"]; export type IsolationLevel = ArrayItemType;