Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transactions support #49

Open
pi0 opened this issue Feb 26, 2024 · 3 comments
Open

Transactions support #49

pi0 opened this issue Feb 26, 2024 · 3 comments

Comments

@pi0
Copy link
Member

pi0 commented Feb 26, 2024

No description provided.

@alex-eri
Copy link

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

@hareland
Copy link
Contributor

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

@BjornTheProgrammer
Copy link

BjornTheProgrammer commented Jan 16, 2025

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]
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants