Reputation: 140
I started with a query call like this:
const query = "SELECT MAX(timeStamp), Temp FROM dataTable WHERE sensorid = " + req.params.id + ";"
After using the docs and cheat sheet, I have something like this:
const query = knex("dataTable").where({'sensorid': req.params.id}).max('timeStamp').first()
But when I console.log(query)
I am getting stuff that I wasn't expecting
Upvotes: 0
Views: 132
Reputation: 35573
Knex returns a Promise, so you need to await
it.
It should look like this:
const query = await knex('dataTable')
.max('timeStamp')
.where({ sensorid: req.params.id })
.first();
Upvotes: 1