@mwcp/kmore
Version:
midway component for knex, supports declarative transaction and OpenTelemetry
31 lines • 1.35 kB
TypeScript
import { DataSourceManager, IMidwayContainer } from '@midwayjs/core';
import { Application, Context } from '@mwcp/share';
import { type Kmore } from 'kmore';
import { DbConfig } from './types.js';
export declare class DbManager<SourceName extends string = string, D extends object = object> extends DataSourceManager<Kmore> {
private readonly sourceConfig;
readonly app: Application;
readonly applicationContext: IMidwayContainer;
private readonly logger;
readonly baseDir: string;
private readonly dbEvent;
private readonly dbHook;
private readonly trxStatusSvc;
init(): Promise<void>;
getDbConfigByDbId(dbId: SourceName): DbConfig | undefined;
protected getWebContext(): Context | undefined;
protected getWebContextThenApp(): Context | Application;
getName(): string;
checkConnected(dataSource: Kmore): Promise<boolean>;
/**
* 创建单个实例
*/
protected createDataSource<Db extends object>(config: DbConfig<Db>, dataSourceName: SourceName): Promise<Kmore<Db> | undefined>;
getDataSource<Db extends object = D>(this: DbManager<SourceName, D>, dataSourceName: SourceName): Kmore<Db>;
destroyDataSource(dataSource: Kmore): Promise<void>;
/**
* 创建单个实例
*/
private _createDataSource;
}
//# sourceMappingURL=db-source-manager.d.ts.map