Skip to content

Instantly share code, notes, and snippets.

@robhanlon22
Last active December 21, 2015 13:39
Show Gist options
  • Save robhanlon22/6314151 to your computer and use it in GitHub Desktop.
Save robhanlon22/6314151 to your computer and use it in GitHub Desktop.
// 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