influxdb.js
821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
*
* @author: jiangfeng<jeff.jiang@yoho.cn>
* @date: 2016/7/29
*/
const influx = require('influx');
let client = influx({
hosts: [{
host: '54.222.219.223',
port: 8086,
protocol: 'http'
}],
database: 'udp'
});
client.getSeriesNames((err, dbs) => {
console.log(err);
console.log(JSON.stringify(dbs));
});
client.query('select * from test_point limit 10', function(err, results) {
console.log(results);
});
const db = {
client: client,
query: (query) => {
return new Promise((resolve, reject) => {
client.query(query, (err, result) => {
if (err) {
reject(err);
} else {
resolve(result);
}
});
});
}
};
module.exports = db;