Skip to content

Commit 9622fe6

Browse files
authored
Merge pull request #192 from kuzzleio/fix-scroll-method
[HOTFIX] Collection.scroll: the scroll parameter is now optional
2 parents 3c3150f + 5deb313 commit 9622fe6

File tree

4 files changed

+10
-20
lines changed

4 files changed

+10
-20
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
Official Kuzzle Javascript SDK
55
======
66

7-
8-
Please use SDK v1.x for earlier versions of Kuzzle.
7+
This SDK version is compatible with Kuzzle 1.0.0-RC9.5 and higher
98

109
## About Kuzzle
1110

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kuzzle-sdk",
3-
"version": "3.4.1",
3+
"version": "3.4.2",
44
"description": "Official Javascript SDK for Kuzzle",
55
"author": "The Kuzzle Team <[email protected]>",
66
"repository": {

src/Collection.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ Collection.prototype.search = function (filters, options, cb) {
490490
*/
491491
Collection.prototype.scroll = function (scrollId, options, filters, cb) {
492492
var
493-
request = {body:{}},
493+
request = {},
494494
self = this;
495495

496496
if (!scrollId) {
@@ -507,17 +507,13 @@ Collection.prototype.scroll = function (scrollId, options, filters, cb) {
507507
options = {};
508508
}
509509

510-
if (!options) {
511-
options = {};
512-
}
513-
514-
if (!options.scroll) {
515-
throw new Error('Collection.scroll: scroll is required');
516-
}
510+
this.kuzzle.callbackRequired('Collection.scroll', cb);
517511

518-
options.scrollId = scrollId;
512+
request.scrollId = scrollId;
519513

520-
this.kuzzle.callbackRequired('Collection.scroll', cb);
514+
if (options && options.scroll) {
515+
request.scroll = options.scroll;
516+
}
521517

522518
this.kuzzle.query({controller: 'document', action: 'scroll'}, request, options, function (error, result) {
523519
var documents = [];

test/Collection/methods.test.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,6 @@ describe('Collection methods', function () {
149149
should(() => { collection.scroll(); }).throw('Collection.scroll: scrollId is required');
150150
});
151151

152-
it('should throw an error if no scroll is provided', () => {
153-
var collection = kuzzle.collection(expectedQuery.collection);
154-
should(() => { collection.scroll('scrollId'); }).throw('Collection.scroll: scroll is required');
155-
});
156-
157152
it('should throw an error if no callback is given', () => {
158153
var collection = kuzzle.collection(expectedQuery.collection);
159154
should(() => { collection.scroll('scrollId', {scroll: '1m'}); }).throw('Collection.scroll: a callback argument is required for read queries');
@@ -173,8 +168,8 @@ describe('Collection methods', function () {
173168
queryScrollStub = function (args, query, opts, callback) {
174169
should(args.controller).be.exactly('document');
175170
should(args.action).be.exactly('scroll');
176-
should(opts.scroll).be.exactly(options.scroll);
177-
should(opts.scrollId).be.exactly(scrollId);
171+
should(query.scroll).be.exactly(options.scroll);
172+
should(query.scrollId).be.exactly(scrollId);
178173

179174
callback(null, {
180175
result: {

0 commit comments

Comments
 (0)