influxdb.js 658 Bytes
/**
 *
 * @author: jiangfeng<jeff.jiang@yoho.cn>
 * @date: 2016/7/29
 */

const influx = require('influx');

let client = influx({
    hosts: [{
        host: 'influxdblog.yohoops.org',
        port: 8086,
        protocol: 'http'
        
    }],
    database: 'udp'
});

const db = {
    client: client,
    query: (query) => {
        console.log(query);
        return new Promise((resolve, reject) => {
            client.query(query, (err, result) => {
                if (err) {
                    reject(err);
                } else {
                    resolve(result);
                }
            });
        });
    }
};

module.exports = db;