-
-
Save brianc/784517 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 cs = "postgres://blarg:blarg@localhost/blarg-upload-development"; | |
pg.connect( cs, function( err, client ) { | |
//check for a connection error | |
if(err) { | |
console.log(err); | |
return; | |
} | |
var filename = "foobar"; | |
var directoryId = 12345; | |
var query = client.query("INSERT INTO uploads(filename, directory_id) VALUES($1, $2)", [filename, directoryId]); | |
query.on('error', console.log); //this will log the error to the console | |
query.on('end', function() { | |
console.log("The query finished"); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment