Skip to content

Instantly share code, notes, and snippets.

@kylemocode
Created July 4, 2022 15:20
Show Gist options
  • Save kylemocode/5d2c5c04f78642d835d27b05f658c59f to your computer and use it in GitHub Desktop.
Save kylemocode/5d2c5c04f78642d835d27b05f658c59f to your computer and use it in GitHub Desktop.
// 開始一個 transaction
await conn.query("BEGIN");
// 執行更新
const sqlU= "update seats set isbooked = 1, name = $2 where id = $1 and isbooked = 0"
const updateResult = await conn.query(sqlU,[id, name]);
// 結束 transaction
await conn.query("COMMIT");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment