High-level database service combining repository access, unit of work, raw queries, and lifecycle management.
Since 0.1.0
getRepository<Entity, Id extends EntityKey = string>(entity: string): IRepository<Entity, Id>
Get a repository for the named entity type.
Since 0.1.0
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.
Since 0.1.0
query<T>(sql: string,params?: unknown[]): Promise<T[]>
Execute a raw SQL query and return results.
Since 0.1.0
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.
Since 0.1.0
isHealthy(): Promise<boolean>
Health-check probe: verifies the database connection is alive.
Since 0.1.0
close(): Promise<void>
Gracefully close all database connections.