0

I want to create a service that receives an entity and creates a repository

this is my trials:

export class MyService<T extends ObjectLiteral> {
  protected repo: Repository<T>;

  constructor(entity: T) {
   let token = getRepositoryToken(entity);
   this.repo = InjectRepository(entity)(this, 'repo');
  }

// methods
}

usage:

let service = new MyService(MyEntity)
service.repo.findmany()
1
  • I think you can help @Jay McDoniel Commented 58 mins ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.