1.0.1 • Published 6 years ago

pg-create-drop-db v1.0.1

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

pg-create-drop-db

Simple module for create if not exists or drop database.

Install

$ npm i pg-create-drop-db

Usage

create(options)

Creates a database if it does not exist.

const {create, drop}=require('pg-create-drop-db');

create({
    user: "postgres",
    pass: "postgres",
    host: "localhost",
    port: 5432,
    name: "db-name", //name for database
    database: "postgres" //the database through which the connection is made
})
.then(() => {
    //db created or exists
});
OptionDescriptionDefault
userDirectory to put all default forever log files'postgres'
passPasswordnull
hostHost'localhost'
portPort5432
nameThe name of a database to create.
databaseThe database through which the connection is made'postgres'
ownerThe role name of the user who will own the new database, or DEFAULT to use the default (namely, the user executing the command). To create a database owned by another role, you must be a direct or indirect member of that role, or be a superuser.
encoding'UTF-8'

drop(options)

Deletes the database.

const {create, drop}=require('pg-create-drop-db');

drop({
    user: "postgres",
    pass: "postgres",
    host: "localhost",
    port: 5432,
    name: "db-name", //name for database
    database: "postgres" //the database through which the connection is made
})
.then(() => {
    //db dropped
});
OptionDescriptionDefault
userDirectory to put all default forever log files'postgres'
passPasswordnull
hostHost'localhost'
portPort5432
nameThe name of a database to drop.
databaseThe database through which the connection is made'postgres'