nesting db calls in transactions without using the callback argument
What is the point of the trx argument when calling db.transaction()?
when using raw sql, a transaction looks something like
so the queries don't really have to "know" that they are inside a transaction, so my question is, is this possible?
if this is not possible: is there any way of nesting inserts without passing the trx argument around? I'd rather keep those things outside functions like insertPlaceDetails, which would now need to "know" about its context. Thanks!
4 Replies
bump I guess?
🤔
You need to use tx in the transaction to guarantee atomicity of the transaction.
This is tx that will wrap everything and handle rollback on error
You could look at https://drizzle.run/lt295lgldz4avpzwdee7ddhd if you want functions that can take a tx or default to db
Drizzle Run
Transaction or DB - Drizzle Run
Thanks a lot!