database-js-postgres

Database-js wrapper for PostgreSQL

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
database-js-postgres
121.1.36 years ago7 years agoMinified + gzip package size for database-js-postgres in KB

Readme

database-js-postgres
Build Status Database-js wrapper for PostgreSQL

About

Database-js-postgres is a wrapper around the node-postgres package by Brian Carlson. It is intended to be used with the database-js package. However it can also be used in stand alone mode. The only reason to do that would be to use Promises.

Usage

Stand Alone

var postgres = require('database-js-postgres'); (async () => {
let connection, rows;
connection = postgres.open({
Hostname: localhost,
Port: 5432,
Username: 'my_secret_username',
Password: 'my_secret_password',
Database: 'my_top_secret_database'
});
try {
rows = await connection.query("SELECT * FROM tablea WHERE user_name = 'not_so_secret_user'");
console.log(rows);
} catch (error) {
console.log(error);
} finally {
await connection.close();
}
})();

With Database-js

var Database = require('database-js2').Connection; (async () => {
let connection, statement, rows;
connection = new Database('database-js-postgres://my_secret_username:my_secret_password@localhost:5432/my_top_secret_database');
try {
statement = await connection.prepareStatement("SELECT * FROM tablea WHERE user_name = ?");
rows = await statement.query('not_so_secret_user');
console.log(rows);
} catch (error) {
console.log(error);
} finally {
await connection.close();
}
})();