Skip to content

Instantly share code, notes, and snippets.

@rlemon

rlemon/db.js Secret

Created May 2, 2014 15:41
Show Gist options
  • Save rlemon/3fd38f54a70a07a04dde to your computer and use it in GitHub Desktop.
Save rlemon/3fd38f54a70a07a04dde to your computer and use it in GitHub Desktop.
var Promise = require('bluebird');
Promise.longStackTraces();
var pg = Promise.promisifyAll(require('pg'));
var connString = '****************************************';
module.exports.getSubscribers = function() {
return pg.connectAsync(connString).bind({}).then(function(client, done) {
this.done = done;
return Promise.promisifyAll(client).queryAsync('SELECT * FROM subscribers');
}).then(function(res) {
this.done();
return res;
}).finally(function() {
pg.end();
});
};
Possibly unhandled TypeError: Object [object Object],function (err) {
at Object.<anonymous> (/modules/db.js:9:39)
From previous event:
at connectAsync (eval at makeNodePromisifiedEval (/node_modules/bluebird/js/main/promisify.js:198:12), <anonymous>:2:125)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment