embedded-postgres
is available from NPM:
npm i embedded-postgres
This package contains a simple API that allows you to create clusters, start them, create / delete database and stop any existing processes.
import EmbeddedPostgres from 'embedded-postgres';
async function main() {
// Create the object
const pg = new EmbeddedPostgres({
data_dir: './data/db',
user: 'postgres',
password: 'password',
port: 5432,
persistent: true,
});
// Create the cluster config files
await pg.initialise();
// Start the server
await pg.start();
// Create and/or drop database
await pg.createDatabase('TEST');
await pg.dropDatabase('TEST');
// Initialize a node-postgres client
const client = pg.getPgClient();
await client.connect();
const result = await client.query('SELECT datname FROM pg_database');
// Stop the server
await pg.stop();
}
main();
This package aims to track the PostgresQL support policy for supported versions. Additionally, we track the binaries that are created upstream in zonky's embedded-postgres-binaries. This leads to the following current support matrix:
Platform / Architecture | 11.20.0 | 12.15.0 | 13.11.0 | 14.8.0 | 15.3.0 |
---|---|---|---|---|---|
π Darwin / x64 | β | β | β | β | β |
π Darwin / arm64[1] | π« | π« | π« | π« | β |
πͺ Windows / x64 | β | β | β | β | β |
π§ Linux / x64 | β | β | β | β | β |
π§ Linux / arm | β | β | β | β | β |
π§ Linux / arm64 | β | β | β | β | β |
π§ Linux / ia32 | β | β | β | β | β |
π§ Linux / ppc64 | β | β | β | β | β |
In order to install a particular version, look for the latest tag in
NPM. For example, if you
would like to install v10.20.0
, you can currently use the following tag:
npm i embedded-postgres@10.20.0-beta.6
Installing particular versions of PostgresQL (i.e. versions not released on NPM) is currently not possible. If you would have a need for doing so, please create an issue.
This package is open to issues, feedback, ideas and pull requests. Create an issue on this repository to get started!
Embedded Postgres was created by Lei Nelissen for BMD Studio. It is based on zonky's embedded-postgres-binaries. The binaries are made available under the Apache License 2.0, whereas the specific code in this package is made available under the MIT license.