I’m using JavaScript (NodeJS) to run GridDB NodeJS client on my Ubuntu machine. I have stored my time series database in a griddb container. I need to find a way to select a table and sort it by the timestamps. It returns the table with the sorted rows where the timestamps are sorted in a descending order, or the most recent time comes last. Do you think there’s a way to do that?
Below is a code snippet for a sample time series database as I stored mine in the GridDB container:
// preliminary codes have been deleted
let time_series;
store.putContainer(timeConInfo, false)
.then(ts => {
time_series = ts;
return ts.put([new Date(), 60, 'resting']);
})
.then(() => {
query = time_series.query(" "); // the query goes here
return query.fetch();
})
.then(rowset => {
while (rowset.hasNext()) {
var row = rowset.next();
console.log("Time =", row[0], "Value =", row[1].toString());
}
})
// catch the exception
.catch(err => {
if (err.constructor.name == "GSException") {
for (var i = 0; i < err.getErrorStackSize(); i++) {
console.log("[", i, "]");
console.log(err.getErrorCode(i));
console.log(err.getMessage(i));
}
} else {
console.log(err);
}
});