db0
db0 copied to clipboard
Transactions support
trafficstars
Also need connection pooling. To lock connection while concurrent request entered transaction.
Would be interesting in contributing to this with some more details:)
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]
})