Cannot use a custom repository without an entity
xtrinch opened this issue · comments
Since I can't leave comments on closed issue, I'm opening a new one.
I'd like to use a custom repository without an entity, and the advice in the issue is to extend Repository
. But you cannot extend repository without the entity, you have to put e.g. Repository<User>
. But my repository doesn't have an entity, so I have to hack it with some other entity just to make this work.
Is this the desired way?
It would be ideal to be able to use it like the docs instruct: https://orkhan.gitbook.io/typeorm/docs/custom-repository#custom-repository-without-extends
@EntityRepository()
export class UserRepository {
constructor(private manager: EntityManager) {
}
...
}
I've already replied to this issue #904 (comment). If you don't want to extend the Repository
class, just define a regular NestJS provider and inject the EntityManager
. There's no reason to use the @EntityRepository()
in this case.
Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.