0.0.2 • Published 5 years ago

pg-wait-connection v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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

NameTypeRequiredDefault valueDescription
poolPoolyes-Pg Pool (see documentation)
querystringnoSELECT 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)
retrynumberno10The number of attempts after which checks are stopped
debugbooleannofalseEnable logs
0.0.2

5 years ago

0.0.1

5 years ago