influxdb.js 821 Bytes
/**
 *
 * @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;