Created
July 9, 2013 03:34
-
-
Save pphetra/5954499 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| }); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
อย่าลืม done() ที่บรรทัดที่ 12