-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom repository example #44
Comments
Thanks @MattIzSpooky, it helped a lot! Just created an issue in the documentation repository: nestjs/docs.nestjs.com#136 |
Helped me a lot, thank you! Just a small note, @kamilmysliwiec @MattIzSpooky - it's not necessary to include |
I'm submitting a basic example
Current behavior
It is not clear how to properly inject a custom repository into their services, this is sadly not documented. People will look through old GitHub issues to find how others managed to solve their issues, this is far from ideal for various reasons.
Expected behavior
A properly documented example so that people can figure out how to do it themselves.
Solution
First create your custom repository. I threw in some useless functions to show that it works.
Then go to your feature module
Now we go to our service
Voila! You're done, you can now use your custom repository as if it was a default repository but with your own extra goodies!
Some proof that it works:
I use GraphQL so here's the other code:
Execute the mutation
Result
Database
Console, to show that the
console.log
function is called.What is the motivation / use case for changing the behavior?
There's a risk people will use outdated answers like this one
People are more likely to look for other people's answers rather than finding their own.
Environment
The text was updated successfully, but these errors were encountered: