How can I extend Repository in a generic way?
See original GitHub issueIssue type:
[*] question [ ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql
/ mariadb
[ ] oracle
[*] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
TypeORM version:
[ ] latest
[ ] @next
[0.1.21] 0.x.x
(or put your version here)
Hi I’m using typeorm with routing-controllers to create a rest endpoint. I want to exend base repository class to have a method named saveAndReturn() which first calls a save() and the returns findOneById() to use for Put and Post request to send the newly created or updated object with default values in place. because I need this for all my repositories I can not use current approaches mentioned in here cause I need it to be generic. How can I do it? thanks
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (2 by maintainers)
Top GitHub Comments
ORM provides you all functionality you need. You can organize classes whatever way you want, it does not depend on ORM. I even was thinking to drop custom repositories support since its one of the opinionated way how to organize your code. You can create hundred of others, orm provides all you need, everything else is up to you. If you need something that manages more then one entity then create that class and don’t use custom repositories functionality. Repository is one repository for each entity in orm context. You probably need something else that you can create.
my way
generic repository:
use: