Skip to content

Commit ffcf2d2

Browse files
author
Burcu Dogan
committed
Merge pull request #23 from silvolu/master
Fix pagination for queries with offset.
2 parents bb7a70a + ad9626e commit ffcf2d2

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/datastore/query.js

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Query.prototype.select = function(fieldNames) {
7676
Query.prototype.start = function(start) {
7777
var q = util.extend(this, new Query());
7878
q.startVal = start;
79+
q.offsetVal = 0;
7980
return q;
8081
}
8182

test/datastore.query.js

+7
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ describe('Query', function() {
112112
done();
113113
});
114114

115+
it('should reset the offset to 0 when using start tokens', function(done) {
116+
var q = ds.createQuery(['kind1']).offset(5);
117+
q.start('startVal');
118+
assert.strictEqual(q.offsetVal, 0);
119+
done();
120+
});
121+
115122
it('should be converted to a query proto successfully', function(done) {
116123
var q = ds.createQuery(['Kind'])
117124
.select(['name', 'count'])

0 commit comments

Comments
 (0)