Callback-free transactions - @transactional decorator
#2349
Omer-Shahar
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I had an idea to write decorators for running transactions in a more convenient way:
This code will also work when moving some of the logic to another method - without the need to pass the
dbobject as an argument.The
dbobject imported fromdb.tswill automatically use the correct object for the transaction.Notice the new
db.isTransactingproperty, which istrueonly when running inside a transaction.If you want to use the global
dbobject even when inside a transaction, you can use thedb.baseDBproperty.This is the link to the repo.
Feel free to ask questions, add improvements and fix any bugs that you find :)
Beta Was this translation helpful? Give feedback.
All reactions