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
In our current project we're on the way to use this lib to resolve some issues which we're facing with TypeORM core transaction. But we found that this lib just supported class method decorator. I implemented two helpers that can help to run transaction in the middle of the method/function body or wrap the a function that will run in transaction
function myService() {
// do something here, e.g. call external service to get data
....
TransactionRunner.run(() => {
....
})
}
Or wrap a function:
function myService() {
// do something
.....
}
export default wrapInTransaction(myService);
But the problem is that I couldn't found a way to pass Propagation and Isolation option to these functions. Is there any suggestion or it's reasonable to create a new PR that will extract the logic from Transactional.ts?
Firstly, thank for your awesome lib @odavid !
In our current project we're on the way to use this lib to resolve some issues which we're facing with TypeORM core transaction. But we found that this lib just supported class method decorator. I implemented two helpers that can help to run transaction in the middle of the method/function body or wrap the a function that will run in transaction
Then we can use it like this:
Or wrap a function:
But the problem is that I couldn't found a way to pass Propagation and Isolation option to these functions. Is there any suggestion or it's reasonable to create a new PR that will extract the logic from Transactional.ts?