Adding new features - the ability to view readings from a custom time period
Adding persistence gives us a very small end result even though there is a lot going on under the hood. Now is the best time to make use of the power we have with SQLite to add more features to our application.
Adding the required APIs
Just like in the previous section, we will need to start by adding the APIs to get the readings and their average for a certain time period:
app.get('/temperature/range',function(req, res){/** * Here, the "start" and "end" datetimes for the range of readings are * expected to be received through the query parameters. This is spllied as part * of the URL request */const{start, end}= req.query /** * The "fetchReadingsBetweenTime" method is called, which returns an array of results, which we return as JSON to the client side */ databaseOperations.fetchReadingsBetweenTime ('temperature', start, end,(err, results...