q-postgres
Postgres with promises.
Sample
var env = process.env.NODE_ENV || 'development';
var props = require('./server.json')[env];
var db = props.db;
var poolPostgres = new qPostgres(db.user, db.pass, db.host, db.base, process.env.DATABASE_URL);
poolPostgres.connect().then(function(connection) {
return connection.openTransaction().then(createTableMigrations).then(function(transaction) {
var sql = 'SELECT * FROM table_name';
return transaction.runScript(sql).then(function(res) {
returm transaction.commit().then(function() {
return res.rows;
});
}).catch(transaction.rollback);
}).then(function() {
connection.end();
});
});