import { type ControlledTransaction, type Dialect, Kysely } from 'kysely'; import { type AnyEntity, Connection, type Dictionary, type EntityData, type IsolationLevel, type LogContext, type LoggingOptions, type MaybePromise, type QueryResult, RawQueryFragment, type Transaction, type TransactionEventBroadcaster, } from '@mikro-orm/core'; import type { AbstractSqlPlatform } from './AbstractSqlPlatform.js'; import { NativeQueryBuilder } from './query/NativeQueryBuilder.js'; /** Base class for SQL database connections, built on top of Kysely. */ export declare abstract class AbstractSqlConnection extends Connection { #private; protected platform: AbstractSqlPlatform; /** Creates a Kysely dialect instance with driver-specific configuration. */ abstract createKyselyDialect(overrides: Dictionary): MaybePromise; /** Establishes the database connection and runs the onConnect hook. */ connect(options?: { skipOnConnect?: boolean }): Promise; /** Initializes the Kysely client from driver options or a user-provided Kysely instance. */ createKysely(): MaybePromise; /** * @inheritDoc */ close(force?: boolean): Promise; /** * @inheritDoc */ isConnected(): Promise; /** * @inheritDoc */ checkConnection(): Promise< | { ok: true; } | { ok: false; reason: string; error?: Error; } >; /** Returns the underlying Kysely client, creating it synchronously if needed. */ getClient(): Kysely; /** Ensures the Kysely client is initialized, creating it asynchronously if needed. */ initClient(): Promise; /** Executes a callback within a transaction, committing on success and rolling back on error. */ transactional( cb: (trx: Transaction>) => Promise, options?: { isolationLevel?: IsolationLevel; readOnly?: boolean; ctx?: ControlledTransaction; eventBroadcaster?: TransactionEventBroadcaster; loggerContext?: LogContext; }, ): Promise; /** Begins a new transaction or creates a savepoint if a transaction context already exists. */ begin(options?: { isolationLevel?: IsolationLevel; readOnly?: boolean; ctx?: ControlledTransaction; eventBroadcaster?: TransactionEventBroadcaster; loggerContext?: LogContext; }): Promise>; /** Commits the transaction or releases the savepoint. */ commit( ctx: ControlledTransaction, eventBroadcaster?: TransactionEventBroadcaster, loggerContext?: LogContext, ): Promise; /** Rolls back the transaction or rolls back to the savepoint. */ rollback( ctx: ControlledTransaction, eventBroadcaster?: TransactionEventBroadcaster, loggerContext?: LogContext, ): Promise; private prepareQuery; /** Executes a SQL query and returns the result based on the method: `'all'` for rows, `'get'` for single row, `'run'` for affected count. */ execute | EntityData[] = EntityData[]>( query: string | NativeQueryBuilder | RawQueryFragment, params?: readonly unknown[], method?: 'all' | 'get' | 'run', ctx?: Transaction, loggerContext?: LoggingOptions, ): Promise; /** Executes a SQL query and returns an async iterable that yields results row by row. */ stream>( query: string | NativeQueryBuilder | RawQueryFragment, params?: readonly unknown[], ctx?: Transaction>, loggerContext?: LoggingOptions, ): AsyncIterableIterator; /** @inheritDoc */ executeDump(dump: string): Promise; protected getSql(query: string, formatted: string, context?: LogContext): string; protected transformRawResult(res: any, method?: 'all' | 'get' | 'run'): T; }