Skip to content

Commit a1588b3

Browse files
committed
feat: update influx-ql for multi query #27
1 parent a8a4d27 commit a1588b3

File tree

6 files changed

+98
-40
lines changed

6 files changed

+98
-40
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ docs
55
jsdoc.json
66
extends
77
assets
8+
yarn*

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,28 @@ client.query('http')
140140
}).catch(console.error);
141141
```
142142

143+
Multi query
144+
145+
```js
146+
const Influx = require('influxdb-nodejs');
147+
const client = new Influx('http://127.0.0.1:8086/mydb');
148+
const reader = client.query('request');
149+
reader.set({
150+
limit: 2,
151+
});
152+
reader.multiQuery();
153+
reader.measurement = 'login';
154+
reader.set({
155+
limit: 1,
156+
});
157+
reader.set({
158+
format: 'json',
159+
});
160+
reader.then(data => {
161+
console.info(JSON.stringify(data));
162+
}).catch(console.error);
163+
```
164+
143165
Use influxdb for express
144166

145167
```js

examples/read-points.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const client = new Influx('http://127.0.0.1:8086/mydb');
1010
reader.start = '-3h';
1111
reader.limit = 2;
1212
reader.condition('spdy', '0');
13-
reader.addCondition('use <= 300');
13+
reader.where('use <= 300');
1414
reader.fill = 0;
1515
reader.then(data => {
1616
console.info(JSON.stringify(data));
@@ -31,3 +31,21 @@ const client = new Influx('http://127.0.0.1:8086/mydb');
3131
console.error(err);
3232
});
3333
}
34+
35+
{
36+
const reader = client.query('request');
37+
reader.set({
38+
limit: 2,
39+
});
40+
reader.multiQuery();
41+
reader.measurement = 'login';
42+
reader.set({
43+
limit: 1,
44+
});
45+
reader.set({
46+
format: 'json',
47+
});
48+
reader.then(data => {
49+
console.info(JSON.stringify(data));
50+
}).catch(console.error);
51+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "influxdb-nodejs",
33
"description": "node.js influxdb client",
4-
"version": "2.7.7",
4+
"version": "2.8.0",
55
"author": "Tree Xie <vicansocanbico@gmail.com>",
66
"keywords": [
77
"influx",
@@ -24,7 +24,7 @@
2424
},
2525
"dependencies": {
2626
"debug": "^3.1.0",
27-
"influx-ql": "^2.6.3",
27+
"influx-ql": "^2.7.0",
2828
"lodash": "^4.17.10",
2929
"nano-seconds": "^1.2.2",
3030
"superagent": "^3.8.3",

test/reader.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,23 @@ describe('Reader', () => {
129129
}).catch(done);
130130
});
131131

132+
it('multi query', done => {
133+
const reader = new Reader(influx);
134+
reader.measurement = 'http';
135+
reader.condition('method', 'get');
136+
reader.multiQuery();
137+
reader.measurement = 'http';
138+
reader.condition('method', 'post');
139+
reader.then(data => {
140+
assert.equal(data.results.length, 2);
141+
assert.equal(data.results[0].statement_id, 0);
142+
assert.equal(data.results[0].series.length, 1);
143+
assert.equal(data.results[1].statement_id, 1);
144+
assert.equal(data.results[1].series.length, 1);
145+
done();
146+
}).catch(done);
147+
});
148+
132149
it('drop db', function(done) {
133150
this.timeout(5000);
134151
influx.dropDatabase(db).then(data => {

yarn.lock

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ acorn@^3.0.4:
2121
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"
2222

2323
acorn@^5.5.0:
24-
version "5.5.3"
25-
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.5.3.tgz#f473dd47e0277a08e28e9bec5aeeb04751f0b8c9"
24+
version "5.7.1"
25+
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.7.1.tgz#f095829297706a7c9776958c0afc8930a9b9d9d8"
2626

2727
ajv-keywords@^1.0.0:
2828
version "1.5.1"
@@ -130,8 +130,8 @@ browser-stdout@1.3.0:
130130
resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f"
131131

132132
buffer-from@^1.0.0:
133-
version "1.0.0"
134-
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.0.0.tgz#4cb8832d23612589b0406e9e2956c17f06fdf531"
133+
version "1.1.0"
134+
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.0.tgz#87fcaa3a298358e0ade6e442cfce840740d1ad04"
135135

136136
builtin-modules@^1.0.0:
137137
version "1.1.1"
@@ -238,8 +238,8 @@ contains-path@^0.1.0:
238238
resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a"
239239

240240
cookiejar@^2.1.0:
241-
version "2.1.1"
242-
resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.1.tgz#41ad57b1b555951ec171412a81942b1e8200d34a"
241+
version "2.1.2"
242+
resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c"
243243

244244
core-util-is@~1.0.0:
245245
version "1.0.2"
@@ -330,14 +330,14 @@ doctrine@^2.0.0:
330330
esutils "^2.0.2"
331331

332332
error-ex@^1.2.0:
333-
version "1.3.1"
334-
resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc"
333+
version "1.3.2"
334+
resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf"
335335
dependencies:
336336
is-arrayish "^0.2.1"
337337

338338
es-abstract@^1.7.0:
339-
version "1.11.0"
340-
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.11.0.tgz#cce87d518f0496893b1a30cd8461835535480681"
339+
version "1.12.0"
340+
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.12.0.tgz#9dbbdd27c6856f0001421ca18782d786bf8a6165"
341341
dependencies:
342342
es-to-primitive "^1.1.1"
343343
function-bind "^1.1.1"
@@ -354,8 +354,8 @@ es-to-primitive@^1.1.1:
354354
is-symbol "^1.0.1"
355355

356356
es5-ext@^0.10.14, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14:
357-
version "0.10.42"
358-
resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.42.tgz#8c07dd33af04d5dcd1310b5cef13bea63a89ba8d"
357+
version "0.10.45"
358+
resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.45.tgz#0bfdf7b473da5919d5adf3bd25ceb754fccc3653"
359359
dependencies:
360360
es6-iterator "~2.0.3"
361361
es6-symbol "~3.1.1"
@@ -455,8 +455,8 @@ eslint-module-utils@^2.2.0:
455455
pkg-dir "^1.0.0"
456456

457457
eslint-plugin-import@^2.2.0:
458-
version "2.11.0"
459-
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.11.0.tgz#15aeea37a67499d848e8e981806d4627b5503816"
458+
version "2.13.0"
459+
resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.13.0.tgz#df24f241175e312d91662dc91ca84064caec14ed"
460460
dependencies:
461461
contains-path "^0.1.0"
462462
debug "^2.6.8"
@@ -641,7 +641,7 @@ fs.realpath@^1.0.0:
641641
version "1.0.0"
642642
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
643643

644-
function-bind@^1.0.2, function-bind@^1.1.1:
644+
function-bind@^1.1.1:
645645
version "1.1.1"
646646
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
647647

@@ -739,22 +739,22 @@ has-symbols@^1.0.0:
739739
resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44"
740740

741741
has@^1.0.1:
742-
version "1.0.1"
743-
resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
742+
version "1.0.3"
743+
resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796"
744744
dependencies:
745-
function-bind "^1.0.2"
745+
function-bind "^1.1.1"
746746

747747
he@1.1.1:
748748
version "1.1.1"
749749
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
750750

751751
hosted-git-info@^2.1.4:
752-
version "2.6.0"
753-
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.6.0.tgz#23235b29ab230c576aab0d4f13fc046b0b038222"
752+
version "2.7.1"
753+
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047"
754754

755755
ignore@^3.2.0:
756-
version "3.3.8"
757-
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.8.tgz#3f8e9c35d38708a3a7e0e9abb6c73e7ee7707b2b"
756+
version "3.3.10"
757+
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
758758

759759
imurmurhash@^0.1.4:
760760
version "0.1.4"
@@ -767,9 +767,9 @@ inflight@^1.0.4:
767767
once "^1.3.0"
768768
wrappy "1"
769769

770-
influx-ql@^2.6.3:
771-
version "2.6.3"
772-
resolved "https://registry.yarnpkg.com/influx-ql/-/influx-ql-2.6.3.tgz#a1f2457e1a40cf46e87953f6df5b4fbfd6cbdfd1"
770+
influx-ql@^2.7.0:
771+
version "2.7.0"
772+
resolved "https://registry.yarnpkg.com/influx-ql/-/influx-ql-2.7.0.tgz#38f8ab3c5f6d42275cf7270a9c0ba2552a38d7cc"
773773

774774
inherits@2, inherits@^2.0.3, inherits@~2.0.3:
775775
version "2.0.3"
@@ -812,8 +812,8 @@ is-builtin-module@^1.0.0:
812812
builtin-modules "^1.0.0"
813813

814814
is-callable@^1.1.1, is-callable@^1.1.3:
815-
version "1.1.3"
816-
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
815+
version "1.1.4"
816+
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75"
817817

818818
is-date-object@^1.0.1:
819819
version "1.0.1"
@@ -909,8 +909,8 @@ js-tokens@^3.0.2:
909909
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
910910

911911
js-yaml@3.x, js-yaml@^3.5.1:
912-
version "3.11.0"
913-
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef"
912+
version "3.12.0"
913+
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1"
914914
dependencies:
915915
argparse "^1.0.7"
916916
esprima "^4.0.0"
@@ -1157,8 +1157,8 @@ object-assign@^4.0.1, object-assign@^4.1.0:
11571157
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
11581158

11591159
object-keys@^1.0.11, object-keys@^1.0.8:
1160-
version "1.0.11"
1161-
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
1160+
version "1.0.12"
1161+
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.12.tgz#09c53855377575310cca62f55bb334abff7b3ed2"
11621162

11631163
object.assign@^4.0.4:
11641164
version "4.1.0"
@@ -1202,8 +1202,8 @@ os-homedir@^1.0.0:
12021202
resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"
12031203

12041204
p-limit@^1.1.0:
1205-
version "1.2.0"
1206-
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.2.0.tgz#0e92b6bedcb59f022c13d0f1949dc82d15909f1c"
1205+
version "1.3.0"
1206+
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8"
12071207
dependencies:
12081208
p-try "^1.0.0"
12091209

@@ -1358,8 +1358,8 @@ resolve@1.1.x:
13581358
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
13591359

13601360
resolve@^1.1.6, resolve@^1.5.0, resolve@^1.6.0:
1361-
version "1.7.1"
1362-
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3"
1361+
version "1.8.1"
1362+
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
13631363
dependencies:
13641364
path-parse "^1.0.5"
13651365

@@ -1610,8 +1610,8 @@ validate-npm-package-license@^3.0.1:
16101610
spdx-expression-parse "^3.0.0"
16111611

16121612
which@^1.1.1:
1613-
version "1.3.0"
1614-
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
1613+
version "1.3.1"
1614+
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
16151615
dependencies:
16161616
isexe "^2.0.0"
16171617

0 commit comments

Comments
 (0)