You need to provide some classes and decorators yourself to maintain the same style as typeorm@2.x
.
@EntityRepository(UserEntity)
export class UserRepository extends Repository<UserEntity> {}
↓
@CustomRepository(UserEntity)
export class UserRepository extends Repository<UserEntity> {}
@Module({
exports: [UserService],
imports: [TypeOrmModule.forFeature([UserRepository])],
providers: [UserService],
})
export class UserModule {}
↓
@Module({
exports: [UserService],
imports: [TypeOrmExModule.forCustomRepository([UserRepository])],
providers: [UserService],
})
export class UserModule {}
How about
where
this.myCustomRepository
is the injected custom repository? I was able to use that strategy successfully. TheEntityManager#withRepository
method re-creates the repository and assigns both theEntityManager
and theQueryRunner
instances to it.Note: I'm using this strategy with the
entityManager.transaction((em) => ...)
method so I haven't tested with theQueryRunner#manager
approach.