How do detect if a Transaction failure occurs?

What is the return value of a transaction when it fails mid way, or does it throw an error? Example:
const authorOrNull = await db.transaction(async (tx) => {
const [u] = tx.insert(user).values(val).onConflictDoNothing().returning()

if u:
const [a] = tx.insert(author).values({ uId: u.id }).returning()
return a ?? null
})
const authorOrNull = await db.transaction(async (tx) => {
const [u] = tx.insert(user).values(val).onConflictDoNothing().returning()

if u:
const [a] = tx.insert(author).values({ uId: u.id }).returning()
return a ?? null
})
How will I know when a transaction failure or a rollback has occurred, for example in case of random I/O failure, or resource exhaustion, or when the database connection is down half-way through the transaction
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server