Pure Node.js implementation of PostgreSQL's createdb and dropdb tools.
Only supports connection options and database name at the moment.
npm install --save -g pgtoolscreatedbjs my_awesome_db --user=admin --password=adminconst{ createdb, dropdb }=require("pgtools");// This can also be a connection string// (in which case the database part is ignored and replaced with postgres)constconfig={user: "postgres",password: "some pass",port: 5432,host: "localhost",};awaitcreatedb(config,"test-db");awaitdropdb(config,"test-db");createdb(config: string|pg.ConnectionConfig,dbname: string): Promise<pg.QueryResult<any>>;dropdb(config: string|pg.ConnectionConfig,dbname: string): Promise<pg.QueryResult<any>>;See ./src/index.d.ts for types.
See pg documentation for ConnectionConfig format.
More usage examples in ./src/test.js.
pgtools installs two useful binaries:
createdbjs: which emulates pgtools'createdbfunctionality.dropdbjs: which emulates pgtools'dropdbfunctionality.
We support all LTS versions from 10 and up. We try to keep up with the latest Node.js version.