Last active
December 21, 2015 13:39
-
-
Save robhanlon22/6314151 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
// node_server.js | |
var db = requre('./db'); | |
app.get('/getTest', function(request, response) { | |
var testId = 1; | |
db.getTest(testId, function (err, data) { | |
// I don't actually know how to send data using express. | |
response.pumpThatShitOut(data); | |
}); | |
} | |
// db.js | |
var pg = require('pg').native | |
var db = pg.Client("postgres:///db_name"); | |
exports.getTest = function(testId, callback) { | |
db.query("select * from table;", function (err, data) { | |
if (err) { | |
callback(err) | |
} else { | |
callback(null, doSomeShitWithData(data)); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment