odavid / typeorm-transactional-cls-hooked

A Transactional Method Decorator for typeorm that uses cls-hooked to handle and propagate transactions between different repositories and service methods. Inpired by Spring Trasnactional Annotation and Sequelize CLS
MIT License
524 stars 86 forks source link

Export getEntityManagerOrTransactionManager for usage in custom repositories #13

Closed odavid closed 5 years ago

odavid commented 5 years ago

Simplified the the BaseRepository, so people can copy/paste the code when inheritance is not an option. exported a special function getEntityManagerOrTransactionManager that gets connectionName and original manager, and tries to return the cls scoped entityManager. If the context is not active, will return the original entityManager or will use typeorm getManager function