# @collectai/node-waitfordb

> Waits for db connection to be established and creates db

Latest version **0.2.1** (published 2023-12-04) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @collectai/node-waitfordb
pnpm add @collectai/node-waitfordb
yarn add @collectai/node-waitfordb
bun add @collectai/node-waitfordb
```

Provides the commands `createdb`, `waitfordb`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2023-12-04 |
| First published | 2017-06-28 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 19.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | collectai |

## Links

- npm: https://www.npmjs.com/package/@collectai/node-waitfordb
- Repository: https://github.com/collectai/node-waitfordb
- Homepage: https://github.com/collectai/node-waitfordb#readme
- Issues: https://github.com/collectai/node-waitfordb/issues
- npm.io page: https://npm.io/package/@collectai/node-waitfordb

## Dependencies (4)

- [pg](https://npm.io/package/pg.md) ^8.7.1
- [pg-connection-string](https://npm.io/package/pg-connection-string.md) ^2.5.0
- [@collectai/node-retry](https://npm.io/package/@collectai/node-retry.md) ^0.4.0
- [@collectai/node-logger](https://npm.io/package/@collectai/node-logger.md) ^3.3.2

## Recent versions

- 0.2.1 (latest) — 2023-12-04
- 0.2.0 — 2021-08-17
- 0.1.5 — 2017-10-25
- 0.1.4 — 2017-07-10
- 0.1.3 — 2017-06-30
- 0.1.2 — 2017-06-30
- 0.1.1 — 2017-06-28
- 0.1.0 — 2017-06-28

## README

# node-waitfordb
## Install
`npm install @collectai/node-waitfordb`

## Run
The installer puts the scripts in the node_module/.bin folder, so those can be run from there:

`node $(npm bin)/waitfordb`- wait for database (or database instance) to be created

`node $(npm bin)/createdb`- create database(s) database instance

## Parameters

Environment variables
- **POSTGRES_URL** is used as default source for connection string, but further connection strings can be added as commandline arguments for both the waitfordb and createdb scripts.

- **WAIT_FOR_INSTANCE** the waitfordb script uses only. If set to true, it checks if the instance is up and ignoring the set database name in the connection string(s). 

- **DEBUG** domain root for the log library (see https://github.com/collectai/node-logger )

## Examples

it's recommended to set up in your project's `package.json`. Example:

```
"scripts": {
  "waitfordb": "POSTRGES_URL=postgres://dbuser@dbhostname.com:5432/databasename DEBUG=app* node $(npm bin)/waitfordb"
},
```

then it can be run as:
`npm run waitfordb`

---
_Source: https://npm.io/package/@collectai/node-waitfordb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
