Wednesday, 19 February 2020

Node-PG How do I make this reusable query block with transaction?

I am using node-pg with expressAs per their docs, I have this setup for a pool https://node-postgres.com/guides/async-expressIn one of my express routes, I want to insert into 2 tables or none which I guess means I need to use transactionsnormally, I would write db.query('insert into A values($1,$2)') and be done with itAs per this section HERE https://node-postgres.com/features/transactions I cannot use pool directly with transactionsHow do I add this transaction block to my file containing reusable query method?

Submitted February 19, 2020 at 07:12AM by mypirateapp

No comments:

Post a Comment