egg-influx

0.0.1 • Public • Published

egg-influx

基于 node-influx 封装的influx的egg插件,用于操作InfluxDB数据库。

安装

$ npm i egg-influx --save

配置

// {app_root}/config/plugin.js
exports.influx = {
  enable: true,
  package: 'egg-influx',
};
 
// {app_root}/config/config.{env}.js
config.influx = {
  host: '127.0.0.1',
  port: 8086,
  database: '<database name>',
  username: '<username>',
  password: '<password>',
}

使用方法

const Service = require('egg').Service;
 
class SystemService extends Service {
 
  async get(params) {
    const { influx, Influx } = this.app;
    try {
      const data = await influx.query(query);
      return data;
    } catch (e) {
      ctx.throw(500, e.message);
    }
  }
}
 
module.exports = SystemService;
 

更多用法,参考 node-influx的文档

Package Sidebar

Install

npm i egg-influx

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

2.86 kB

Total Files

6

Last publish

Collaborators

  • frontdog