dario1985 / nestjs-mikro-orm

NestJS MikroORM integration
36 stars 6 forks source link

Inject custom repository #1

Closed javialon26 closed 4 years ago

javialon26 commented 4 years ago

Is there a way to inject a custom repository just like the Typeorm Nest integration?

In Nest TypeOrm if you pass the custom repository to forFeature then you can inject the custom repository everywhere.

I had to try this option but Nest does not recognize the dependency.

B4nan commented 4 years ago

You should get your custom repository automatically, under the hood this just calls em.getRepository() and registers the output into DI container. MikroORM will return instance of custom repository there, if you have it registered (either via @Repository decorator or @Entity({ customRepository: ... })).

https://mikro-orm.io/docs/repositories/#custom-repository

javialon26 commented 4 years ago

Is working now, thank you!