테스팅시
beforeAll(()=>{
await container.clearInstances()
container.register<TypeDB>('DB_CONFIG', {
useFactory: instanceCachingFactory(() => new TypeDB()),
})
})
Transform
//선언
export class RepoTransformer implements Transform<TypeDB, Promise<Repository<any>>> {
public transform(flags: TypeDB, entity: EntityTarget<any>) {
return flags.manager().then((manager) => manager.getRepository(entity))
}
}
//호출시
export class InvestorJobMapper{
constructor(
@injectWithTransform('DB_CONFIG', RepoTransformer, InvestorEntity)
private readonly _investorDAO?: Promise<Repository<InvestorEntity>>
)
}