db0 icon indicating copy to clipboard operation
db0 copied to clipboard

Transactions support

Open pi0 opened this issue 1 year ago • 3 comments
trafficstars

pi0 avatar Feb 26 '24 17:02 pi0

Also need connection pooling. To lock connection while concurrent request entered transaction.

alex-eri avatar Mar 24 '24 08:03 alex-eri

Would be interesting in contributing to this with some more details:)

hareland avatar Oct 19 '24 19:10 hareland

Thanks for all of your hard work on this project!

What API would you have in mind for transactions? Maybe something like the postgres npm packages way of doing so, but more generalized?

const [user, account] = await sql.transaction(async sql => {
  const { rows: userRows } = await sql`
    insert into users (
      name
    ) values (
      'Murray'
    )
    returning *
  `

 const { rows: accountRows } = await sql`
    insert into accounts (
      user_id
    ) values (
      ${ user.user_id }
    )
    returning *
  `

  return [userRows, accountRows]
})

BjornTheProgrammer avatar Jan 16 '25 11:01 BjornTheProgrammer