Skip to content

Commit be17cba

Browse files
authored
Merge pull request #139 from kuzzleio/feature-532-refresh-wait-for
Add refresh as option
2 parents 915296c + a3abff9 commit be17cba

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"bulk"
1919
],
2020
"scripts": {
21-
"test": "npm run --silent lint && istanbul cover _mocha -- --recursive",
21+
"test": "npm run --silent lint && npm run unit-testing",
22+
"unit-testing": "istanbul cover _mocha -- --recursive",
2223
"lint": "eslint --max-warnings=0 ./lib ./test",
2324
"build": "node build.js"
2425
},

src/kuzzle.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,15 +1253,19 @@ Kuzzle.prototype.query = function (queryArgs, query, options, cb) {
12531253
}
12541254

12551255
if (options) {
1256+
if (options.queuable === false && self.state === 'offline') {
1257+
return self;
1258+
}
1259+
1260+
if (options.refresh) {
1261+
object.refresh = options.refresh;
1262+
}
1263+
12561264
if (options.metadata) {
12571265
Object.keys(options.metadata).forEach(function (meta) {
12581266
object.metadata[meta] = options.metadata[meta];
12591267
});
12601268
}
1261-
1262-
if (options.queuable === false && self.state === 'offline') {
1263-
return self;
1264-
}
12651269
}
12661270

12671271
if (!query || typeof query !== 'object' || Array.isArray(query)) {

test/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"func-names": 0,
44
"no-invalid-this": 0,
55
"no-new": 0,
6-
"new-cap": 0
6+
"new-cap": 0,
7+
"no-console": 0
78
}
89
}

test/kuzzle/query.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ describe('Query management', function () {
164164
should(requestObject.metadata).match(metadata);
165165
});
166166

167+
it('should handle option refresh properly', function () {
168+
var
169+
refresh = 'foo';
170+
171+
kuzzle.query(queryArgs, { body: { some: 'query'}}, {refresh: refresh});
172+
should(requestObject.refresh).match(refresh);
173+
});
174+
167175
it('should exit early if the query is not queuable and the SDK is offline', function () {
168176
kuzzle.state = 'offline';
169177
kuzzle.query(queryArgs, { body: { some: 'query'}}, {queuable: false});

0 commit comments

Comments
 (0)