typeorm-polymorphic
typeorm-polymorphic copied to clipboard
The implementation in the readme is wrong.
Or at least, I was having problems with it.
I could not use the extended repository without invoking getCustomRepository
instead of the standard getRepository
as stated in the readme.
@Entity()
export class Address implements PolymorphicChildInterface {
....
}
@EntityRepository(Address)
export class AddressRepository extends AbstractPolymorphicRepository<Address> {}
import { Address, AddressRepository } from '../';
let addressRepository: AbstractPolymorphicRepository<Address>;
addressRepository = await TestConnection.connection.getCustomRepository(AddressRepository);
Ahh sorry, I use this heavily with nestjs so my implementation might be a lot different to yours!
Can you give a complete example?
@codeninja @bashleigh
Can you give a complete example?