【发布时间】:2017-10-26 16:16:25
【问题描述】:
您能帮我从 nodeJS 应用程序内的流入数据库实例中获取数据吗?
我尝试了https://github.com/node-influx/node-influx 和https://github.com/vicanso/influxdb-nodejs,但收效甚微。
const Influx = require('influxdb-nodejs');
//Database connection Influx
const client = new Influx('http://redacted/db');
exports.connectInflux = function () {
var date = new Date();
var timeTo = date.toISOString()
date.setDate(date.getDate() - 4)
var timeFrom = date.toISOString()
var reader = client.query('impulse')
.where('location', 'SA08')
.where('time', timeFrom, '>')
.where('time', timeTo, '<')
.then(function (data) {
console.info(data.results[0].series[0].values)
return data.results[0].series[0].values
})
.catch(console.error);
// I get the measurements
client.showMeasurements()
.then(console.info)
.catch(console.error)
}
有了这段代码sn-p,至少我可以在控制台获取数据了。但是当尝试使用它时,我只得到一个空数组。你能看出这里有什么错误吗?
感谢每一个提示!
谢谢!
【问题讨论】: