How to make a synchronous query (blocking call) with node-postgres?

Dejan picture Dejan · Apr 3, 2013 · Viewed 12.3k times · Source

While booting my Node.js app, I want to make a couple of synchronous calls to the PostgreSQL database to check some things before continuing the control flow. How can I achieve this using the node-postgres package?

Answer

Johannes Griebenow picture Johannes Griebenow · Oct 26, 2017

You can use the pg-native or pg-sync package.