Database service implementation wrapping an ORM adapter.
DatabaseService(_adapter: IDatabaseAdapter,_createDataSource: (entity: string) => DataSource,_adapterType: DatabaseAdapterType,_options?: DatabaseAdapterOptions,_logger?: { debug(msg: string,meta?: Record<string, unknown>): void; },_now?: () => number)
Creates a database service over one adapter and repository data-source factory.
isClosed: boolean
Reports whether close has run — a LIFECYCLE-only read that
reaches no adapter and performs no I/O (M90b).
isHealthy() answers two questions at once: the service's own lifecycle
AND the adapter's readiness. The database health indicator gates on
lifecycle uncached — a closed database must read down immediately,
never from an outcome cached before close — and bounds the adapter
question inside its cached probe. Reading isHealthy() for the gate
therefore called the adapter on the ONE path that is deliberately
outside that bound, and made a poll cost two readiness reads instead of
one. This is the gate.
[DRIZZLE_QUERY_HANDLE](): NativeDrizzleQueryHandle
Provide the configured native Drizzle instance through the internal protocol.
close(): Promise<void>
Gracefully close all database connections.
getRepository<Entity, Id extends EntityKey = string>(entity: string): IRepository<Entity, Id>
Returns a repository bound to the named entity on the outer database scope.
isHealthy(): Promise<boolean>
Health-check probe: verifies the database connection is alive.
migrate(): Promise<void>
Programmatic migrations are unsupported by the current adapters. Each ORM
owns schema migration through its own CLI, so this rejects with
UnsupportedMigrationError.
query<T>(sql: string,params?: unknown[]): Promise<T[]>
Execute a raw SQL query and return results.
transaction<T>(work: (uow: IUnitOfWork) => Promise<T>,options?: TransactionOptions): Promise<T>
Execute the work callback within a database transaction.
On success the transaction commits and the callback result is returned. On error the transaction rolls back and the error propagates.