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

Is propagation type SUPPORTS equivalent to no Transactional decorator? #35

Closed ydinari closed 4 years ago

ydinari commented 4 years ago

Suppose I have function foo() decorated with @Transactional, calling function bar(). Do we get the same behavior if bar is decorated with @Transactional({ propagation: Propagation.SUPPORTS }), or not decorated at all? It seems that way by looking at the logs of start and commit transaction, but I'm not sure this is guaranteed.

odavid commented 4 years ago

Hi @ydinari ,

The answer is yes. SUPPORTS means that it supports the current transaction, but will run without transaction if there is no current transaction.

Hope it helps

ydinari commented 4 years ago

Thanks! Then is there a use case where I need to use Transaction({propagation: Propagation.SUPPORTS})?

odavid commented 4 years ago

Basically I tried to emulate all spring options. I myself, not sure what would be the use case for that.

On Thu, 26 Dec 2019 at 17:15 Yuval Dinari notifications@github.com wrote:

Thanks! Then is there a use case where I need to use Transaction({propagation: Propagation.SUPPORTS})?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/odavid/typeorm-transactional-cls-hooked/issues/35?email_source=notifications&email_token=AAGSOAJ6KCLO4QYLIYB5OF3Q2TDCVA5CNFSM4J7J4WM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHVWHKI#issuecomment-569074601, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGSOALNQFF2G47BJTMYI53Q2TDCVANCNFSM4J7J4WMQ .