var pg = require('pg.js');
var pgTransact = require('pg-transact');
function transaction(client, cb){
client.query('SELECT NOW() as when', function(err, result){
if(err){
return cb(err);
}
cb(null, result);
});
}
pg.connect(connectionString, function(err, client, done){
if(err){
throw err;
}
pgTransact(client, transaction, done)
.then(console.log, console.error);
});
var pg = require('pg.js');
var pgTransact = require('pg-transact');
function transaction(client, cb){
return new Promise(function(resolve, reject){
client.query('SELECT NOW() as when', function(err, result){
if(err){
return reject(err);
}
resolve(result);
});
});
}
pg.connect(connectionString, function(err, client, done){
if(err){
throw err;
}
pgTransact(client, transaction, done)
.then(console.log, console.error);
});