diff --git a/packages/core/src/interface.ts b/packages/core/src/interface.ts index 5c03fe50f4c3..95ac60822004 100644 --- a/packages/core/src/interface.ts +++ b/packages/core/src/interface.ts @@ -488,7 +488,9 @@ export type DataSourceManagerConfigOption & OPTIONS; + }> & OPTIONS & { + customDataSourceClass?: any; + }; }; } & CreateDataSourceInstanceOptions; diff --git a/packages/typeorm/src/dataSourceManager.ts b/packages/typeorm/src/dataSourceManager.ts index c2721c7334b5..b8753a95f71d 100644 --- a/packages/typeorm/src/dataSourceManager.ts +++ b/packages/typeorm/src/dataSourceManager.ts @@ -49,7 +49,16 @@ export class TypeORMDataSourceManager extends DataSourceManager { this.loggerService.getLogger('typeormLogger') ); } - const dataSource = new DataSource(config); + + const { customDataSourceClass, ...otherConfig } = config; + + let dataSource: DataSource; + if (customDataSourceClass) { + dataSource = new customDataSourceClass(otherConfig); + } else { + dataSource = new DataSource(otherConfig); + } + await dataSource.initialize(); return dataSource; }