Fetching the average of readings between time periods

This is similar to the previous query in terms of the information we require in order to obtain the average:

    const getAverageOfReadingsBetweenTime = (type, start, end,
callback) => { db.get(`SELECT avg(value) FROM temperature WHERE
createdAt > ? AND createdAt < ?;`
, [start, end], callback) }

In this function, we're using the get method instead of the all method since we expect only one reading to be returned.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.135.175