Skip to content

Instantly share code, notes, and snippets.

@FrankV01
Created July 4, 2017 17:47
Show Gist options
  • Save FrankV01/d8595ea3f80bf9297989a9f372015bda to your computer and use it in GitHub Desktop.
Save FrankV01/d8595ea3f80bf9297989a9f372015bda to your computer and use it in GitHub Desktop.
client.query('SELECT NOW() as now', (err, res) => {
if (err) {
console.log(err.stack)
} else {
const targetDate = res.rows[0];
client.query(`SELECT * from myTable where lastCreated > ${res.rows[0]}`, (er2, res2) => {
//This, in theory could go on a bit. Note that this is a contrived example and in the case
// of SQL, you'd use the proper joins and conditionals in one statement.
})
}
})
// promise
client.query('SELECT NOW() as now')
.then(res => console.log(res.rows[0]))
.catch(e => console.error(e.stack))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment