Skip to content

Instantly share code, notes, and snippets.

@pphetra
Created July 9, 2013 03:34
Show Gist options
  • Select an option

  • Save pphetra/5954499 to your computer and use it in GitHub Desktop.

Select an option

Save pphetra/5954499 to your computer and use it in GitHub Desktop.
var pg = require('pg');
var conString = "tcp://postgres:1234@localhost/postgres";
pg.connect(conString, function(err, client, done) {
if(err) {
return console.error('error fetching client from pool', err);
}
client.query('SELECT $1::int AS numbor', ['1'], function(err, result) {
//call `done()` to release the client back to the pool
done();
if(err) {
return console.error('error running query', err);
}
console.log(result.rows[0].numbor);
//output: 1
});
});
@pphetra
Copy link
Author

pphetra commented Jul 9, 2013

อย่าลืม done() ที่บรรทัดที่ 12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment