Skip to content

Instantly share code, notes, and snippets.

@harryhan24
Last active January 10, 2023 09:10
Show Gist options
  • Save harryhan24/42e41635a0266210083adf8b28f13f3c to your computer and use it in GitHub Desktop.
Save harryhan24/42e41635a0266210083adf8b28f13f3c to your computer and use it in GitHub Desktop.

테스팅시

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>>
	)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment