11import { Provider } from '@nestjs/common' ;
2- import { DataSource , DataSourceOptions , getMetadataArgsStorage } from 'typeorm' ;
3- import { getDataSourceToken , getRepositoryToken } from './common/typeorm.utils' ;
2+ import { DataSource , DataSourceOptions , EntityManager , getMetadataArgsStorage } from 'typeorm' ;
3+ import { getDataSourceToken , getEntityManagerToken , getRepositoryToken } from './common/typeorm.utils' ;
44import { EntityClassOrSchema } from './interfaces/entity-class-or-schema.type' ;
55
66export function createTypeOrmProviders (
@@ -9,16 +9,16 @@ export function createTypeOrmProviders(
99) : Provider [ ] {
1010 return ( entities || [ ] ) . map ( ( entity ) => ( {
1111 provide : getRepositoryToken ( entity , dataSource ) ,
12- useFactory : ( dataSource : DataSource ) => {
13- const enitityMetadata = dataSource . entityMetadatas . find ( ( meta ) => meta . target === entity )
12+ useFactory : ( entityManager : EntityManager ) => {
13+ const enitityMetadata = entityManager . connection . entityMetadatas . find ( ( meta ) => meta . target === entity )
1414 const isTreeEntity = typeof enitityMetadata ?. treeType !== 'undefined'
15- return isTreeEntity
16- ? dataSource . getTreeRepository ( entity )
17- : dataSource . options . type === 'mongodb'
18- ? dataSource . getMongoRepository ( entity )
19- : dataSource . getRepository ( entity ) ;
15+ return isTreeEntity
16+ ? entityManager . getTreeRepository ( entity )
17+ : entityManager . connection . options . type === 'mongodb'
18+ ? entityManager . getMongoRepository ( entity )
19+ : entityManager . getRepository ( entity ) ;
2020 } ,
21- inject : [ getDataSourceToken ( dataSource ) ] ,
21+ inject : [ getEntityManagerToken ( dataSource ) ] ,
2222 /**
2323 * Extra property to workaround dynamic modules serialisation issue
2424 * that occurs when "TypeOrm#forFeature()" method is called with the same number
0 commit comments