Created
October 7, 2014 14:39
-
-
Save brianc/bfd6ab86eaecc93205af to your computer and use it in GitHub Desktop.
This file contains 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 http = require('http') | |
var pg = require('pg') | |
//creating a single, global client | |
//will potentially cause two requests two issue queries | |
//interleaved within one another... | |
//do not do this! | |
var client = new Client() | |
client.connect() | |
var server = http.createServer(function(req, res) { | |
client.query('BEGIN', function(err) { | |
if(err) throw err; | |
client.query('DO SOMETHING', function(err) { | |
if(err) throw err; | |
client.query('COMMIT', function(err) { | |
if(err) throw err; | |
res.end('okay') | |
}) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment