【问题标题】:Reading data from influxDB in a nodeJS application?在 nodeJS 应用程序中从 influxDB 读取数据?
【发布时间】:2017-10-26 16:16:25
【问题描述】:

您能帮我从 nodeJS 应用程序内的流入数据库实例中获取数据吗?

我尝试了https://github.com/node-influx/node-influxhttps://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,至少我可以在控制台获取数据了。但是当尝试使用它时,我只得到一个空数组。你能看出这里有什么错误吗?

感谢每一个提示!

谢谢!

【问题讨论】:

    标签: node.js influxdb


    【解决方案1】:

    请记住,默认情况下,时间必须以纳秒为单位。您正在使用毫秒。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-04
      • 1970-01-01
      • 2013-04-24
      • 1970-01-01
      • 2015-06-27
      • 1970-01-01
      • 1970-01-01
      • 2017-12-03
      相关资源
      最近更新 更多