node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

Add pg-transaction module

Open brianc opened this issue 5 months ago • 2 comments

I'm taking over the old pg-transaction module, and turning it into a simpler async/await affair. I basically write this same utility in every project I do, so thought it'd be helpful. Pass the transaction function a connected client or an instance of a pool and it will call back with the client (or one checked out from the pool) already within a BEGIN block. If your async callback doesn't throw, it will COMMIT after, and if it does throw, it will ROLLBACK. It also releases the client back to the pool regardless of if the your async callback function throws or not.

brianc avatar Jul 18 '25 14:07 brianc

~todo: add docs~ done

brianc avatar Jul 18 '25 14:07 brianc

Deploying node-postgres with  Cloudflare Pages  Cloudflare Pages

Latest commit: bc627be
Status: ✅  Deploy successful!
Preview URL: https://e885314f.node-postgres.pages.dev
Branch Preview URL: https://bmc-pg-transaction-2.node-postgres.pages.dev

View logs