Skip to content

Instantly share code, notes, and snippets.

@myyellowshoe
Created October 19, 2018 00:02
Show Gist options
  • Save myyellowshoe/add1a17e12961e3cdd852f45f1ba5944 to your computer and use it in GitHub Desktop.
Save myyellowshoe/add1a17e12961e3cdd852f45f1ba5944 to your computer and use it in GitHub Desktop.
app.get('/', (req, res) => {
const client = new Client();
client.connect()
.then(() => {
const sticky = await client.query("SELECT * FROM product_index WHERE product_sticky::boolean = 'true'")
.then((results) => results.rows);
const lowstock = await client.query("SELECT * FROM product_index WHERE product_sticky::boolean = 'true'");
.then((results) => results.rows);
return { sticky, lowstock };
})
.then((results) => {
console.log('results?', results);
client.end();
res.render('home', results);
})
.catch((err) => {
console.log('error'. err);
client.end();
res.send('Something bad happened');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment