Custom repository Error
See original GitHub issueWith typeorm we can use custom repository to override default one to add extra methods.
For example:
@Component()
@EntityRepository(Jwt)
export class JwtRepository extends Repository<Jwt> {
}
After we juste have to inject it inside controller/model/service etc… like this:
constructor(
@OrmRepository('connectionName')
private readonly jwtRepository: jwtRepository,
But only InjectRepository decorator is available on nestjs, so if we try to inject repo into a service:
@Component()
export class MyService {
constructor(
@InjectRepository(Jwt)
private readonly jwtRepository: JwtRepository,
We got this error for any repo function:
Cannot read property 'findOne' of undefined
at JwtRepository.Repository.findOne
How it is possible to use custom repo?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Custom Jpa Repository erroring with Fragment ...
I am currently writing an application in spring boot and am building my own custom repository. First things first, ...
Read more >Synchronizing a custom repository fails with error "Package id ...
Synchronizing a custom repository fails with error "Package id from primary metadata (XXXX), does not match package id from filelists, other ...
Read more >Unable to upload .deb package in custom repository - Support
Problem: We created a custom product and repository in our Foreman 3.1, ... We are facing that error message when trying to upload...
Read more >Error trying to open "SLE Custom Repository Management ...
Hi There!! I'm trying to configure out patches to our Custom SUSE Repository and I'm getting an error when I try to open...
Read more >Get Started with Custom Error Handling in Spring Boot (Java)
So, clone the repository with the following command: git clone https://github.com/Tonel/spring-boot-custom-error-handling.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
After hours of Googling, I finally found a workaround. The solution is still pretty elegant in my opinion, but this should actually be supported out of the box.
The workaround I use, is using a provider.
My image.repository.ts
In the module, simply inject the provider.
E.g. image.module.ts:
Now using @Inject(‘ImageRepository’), you can inject it into your services etc.
@kamilmysliwiec What would be the correct use of this feature? Do you have an example?