Miss any of our Open RFC calls?Watch the recordings here! »

pg-wait-connection

0.0.2 • Public • Published

pg-wait-connection

Wait PostgreSQL connection with node-postgres.

Installation

npm install --save pg-wait-connection

or

yarn add pg-wait-connection

Usage

import { Pool } from 'pg';
import { PgWaitConnection } from 'pg-wait-connection';
 
const pool = new Pool({
  user: 'dbuser',
  host: 'database.server.com',
  database: 'mydb',
  password: 'secretpassword',
  port: 3211,
});
 
const waitConnection = new PgWaitConnection({ pool });
 
await waitConnection.check();

Options

Name Type Required Default value Description
pool Pool yes - Pg Pool (see documentation)
query string no SELECT NOW() SQL-query, which is executed on every check. You can check that the database is available or that the database contains the table/data you need (for example after run migrations)
retry number no 10 The number of attempts after which checks are stopped
debug boolean no false Enable logs

Install

npm i pg-wait-connection

DownloadsWeekly Downloads

4

Version

0.0.2

License

MIT

Unpacked Size

55.6 kB

Total Files

6

Last publish

Collaborators

  • avatar