Node.js连接influxDB
来源:互联网 发布:cad手机绘图软件 编辑:程序博客网 时间:2024/06/11 15:44
Node.js连接influxDB
下载
npm install --save influxdb-nodejs
为了方便,我先封装成Util类
InfluxClient.js
require('./util/CommonUtil');const Influx = require('influxdb-nodejs');const config = require('./config/config').influx;InfluxClient = function() {};InfluxClient.query = function(table, condition, set, callback) { var dblink = 'http://' + config.user + ':' + config.password + '@' + config.host + ':' + config.port + '/' + database; console.log("# dblink:" + dblink); var client = new Influx(dblink); // client.query('video').where('publish = 1').set({limit: 10}).then(console.info).catch(console.error); client.query(table).where(condition).set(set) .then((data) => { var sql = client.query(table).where(condition).set(set).toString(); console.info('## sql: ' + sql); callback(data); }).catch(console.error);};InfluxClient.queryCount = function(database, table, condition, count, callback) { var dblink = 'http://' + config.user + ':' + config.password + '@' + config.host + ':' + config.port + '/' + database; console.log("# dblink:" + dblink); var client = new Influx(dblink); var reader = client.query(table); reader = reader.where(condition); var countArr = count.split(","); for (var i = 0; i <= countArr.length - 1; i++) { reader = reader.addFunction('count', countArr[i], { alias: countArr[i], }); } reader.then((data) => { console.info('## sql: ' + reader.toString()); callback(data); }).catch(console.error);};
阅读全文
0 0
- Node.js连接influxDB
- 使用 StatsD + Grafana + InfluxDB 搭建 Node.js 监控系统
- 使用 StatsD + InfluxDB + Grafana 搭建 Node.js 监控系统 (二)
- node.js连接MySQL
- Node.js连接数据库
- node.js 连接mysql
- node.js连接mongodb
- node.js连接MySQL
- node.js 连接数据库
- Node.JS连接数据库
- Node.js连接MongoDB。
- Node.js 连接 MySQL
- Node.Js连接mysql
- Node JS 连接Mysql 数据库
- Node.js连接数据库总结
- Node.js 连接 Mysql实例
- Node.js连接数据库总结
- 关于 node.js 连接 mysql
- winpe下关闭防火墙
- echarts图例太多做分页处理
- Nodejs学习(5)一个简单的koa2的示例
- 【Jquery学习】第三部分
- ubuntu编译protobuf库
- Node.js连接influxDB
- 程序猿看过来,教你如何使用apktool反编译apk获取资源文件
- convert long UNIX time
- Java基本之数据类型
- 使用SShCoient软件向linex传送文件报错:Encountered 1 errors during the transfer
- PHP Excel上传demo
- js中利用prototype给类添加方法
- MyBatis3 用log4j在控制台输出 SQL
- hdoj 1094