Pure Node.js implementation of PostgreSQL's createdb and dropdb tools.
Only supports connection options and database name at the moment.
npm install --save pgtools
var pgtools = require('pgtools');
pgtools.createdb({
user: 'postgres',
password: 'some pass',
port: 5432,
host: 'localhost'
}, 'test-db', function (err, res) {
if (err) {
console.error(err);
process.exit(-1);
}
console.log(res);
});
pgtools.createdb(config, dbname [, cb(err)])
pgtools.dropdb(config, dbname [, cb(err)])
pgtools.cloneTemplate(config, dbname, templateName [, cb(err)])
-
object config
An object with user, password, port, and host properties.
-
string dbname
The name of the database to create.
-
string templateName
Name of the template to clone from.
-
function cb
A callback that takes an error argument.