pg_tmp for Node
pg_tmp packaged for Node.js.
Installation
npm install --save pg-tmp
Usage
Example usage together with mocha:
const createDatabase = const Client =
API
createDatabase([options]) => Promise
Start a temporary database that will be cleaned up automatically after being used.
Returns a Promise
of a object with the following properties:
host
- The host to connect to, will be the path to a UNIX socketuser
- The user to connect as, currently the name of the current userpassword
- The password to connect with, currently always an empty stringdatabase
- The database to connect to, currently always "test"
options.setEnvironment
If setEnvironment
is either not provided, or set to true, the standard postgresql environmental variables will be set so that you can connect directly without any additional config.
options.timeout
The database will be shut down and removed after the specified timeout (in seconds). If one or more clients are still connected then sleeps and retries again after the same interval.
The default is 60 seconds.