https://github.com/vicanso/influx-ql
Simple way for influx ql
https://github.com/vicanso/influx-ql
influx-ql influxdb
Last synced: 3 months ago
JSON representation
Simple way for influx ql
- Host: GitHub
- URL: https://github.com/vicanso/influx-ql
- Owner: vicanso
- License: mit
- Created: 2016-04-07T14:13:56.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T14:01:56.000Z (almost 3 years ago)
- Last Synced: 2025-06-21T03:52:15.811Z (4 months ago)
- Topics: influx-ql, influxdb
- Language: JavaScript
- Homepage: https://vicanso.github.io/influx-ql/QL.html
- Size: 461 KB
- Stars: 9
- Watchers: 3
- Forks: 4
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
# Influx-ql
[](https://travis-ci.org/vicanso/influx-ql)
[](https://coveralls.io/r/vicanso/influx-ql?branch=master)
[](https://www.npmjs.org/package/influx-ql)
[](https://github.com/vicanso/influx-ql)[Influxdb-nodejs](https://github.com/vicanso/influxdb-nodejs) An Influxdb Node.js Client depends on Influx-ql.
Get influx ql
```js
const QL = require('influx-ql');
const ql = new QL('mydb');
ql.measurement = 'http';
ql.RP = 'default';
ql.addField('status', 'spdy', 'fetch time');
ql.start = '2016-01-01';
ql.end = '-3h';
ql.limit = 10;
ql.slimit = 5;
ql.order = 'desc';
ql.offset = 10;
ql.soffset = 5;
ql.tz = 'America/Chicago';
ql.where('code', 400);
ql.where('"use" <= 30');
// select "fetch time","spdy","status" from "mydb"."default"."http" where "code" = 400 and "use" <= 30 and time <= now() - 3h and time >= '2016-01-01' order by time desc limit 10 slimit 5 offset 10 soffset 5 tz('America/Chicago')
ql.toSelect();
```The enhance where function
```js
const QL = require('influx-ql');
const ql = new QL('mydb');
ql.measurement = 'http';// select * from "mydb".."http" where "spdy" = '1'
ql.where("spdy", "1");
ql.emptyConditions();// select * from "mydb".."http" where ("spdy" = '1' or "spdy" = '2')
ql.where("spdy", ["1", "2"]);
ql.emptyConditions();// select * from "mydb".."http" where "use" >= 300
ql.where("use", 300, ">=");
ql.emptyConditions();// select * from "mydb".."http" where ("spdy" = '1' and "method" = 'GET')
ql.where({spdy: "1", method: "GET"});
ql.emptyConditions();// select * from "mydb".."http" where ("spdy" != '1' and "method" != 'GET')
ql.where({spdy: "1", method: "GET"}, '!=');
ql.emptyConditions();// select * from "mydb".."http" where ("spdy" = '1' or "method" = 'GET')
ql.where({spdy: "1", method: "GET"}, "or");
ql.emptyConditions();// select * from "mydb".."http" where (spdy = '1' and method = 'GET')
ql.where("spdy = '1' and method = 'GET'");
ql.emptyConditions();// select * from "mydb".."http" where "spdy" = /1|2/
ql.where({spdy: /1|2/});
ql.emptyConditions();// select * from "mydb".."http" where "method" = 'GET' or "spdy" = '1'
ql.where('spdy', '1');
ql.where('method', 'GET');
ql.relation = 'or';// select sum("max") from (select max("fetch time") from "mydb".."http" group by "spdy")
ql.clean();
ql.measurement = 'http';
ql.addFunction('max', 'fetch time');
ql.addGroup('spdy');
ql.subQuery();
ql.addFunction('sum', 'max');
```## Installation
```bash
$ npm i influx-ql
```## Examples
View the [./examples](examples) directory for working examples.
## API
[API](https://vicanso.github.io/influx-ql/QL.html)
## License
MIT