Skip to content

Commit

Permalink
Merge pull request #23 from silvolu/master
Browse files Browse the repository at this point in the history
Fix pagination for queries with offset.
  • Loading branch information
Burcu Dogan committed Jul 21, 2014
2 parents bb7a70a + ad9626e commit ffcf2d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/datastore/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Query.prototype.select = function(fieldNames) {
Query.prototype.start = function(start) {
var q = util.extend(this, new Query());
q.startVal = start;
q.offsetVal = 0;
return q;
}

Expand Down
7 changes: 7 additions & 0 deletions test/datastore.query.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ describe('Query', function() {
done();
});

it('should reset the offset to 0 when using start tokens', function(done) {
var q = ds.createQuery(['kind1']).offset(5);
q.start('startVal');
assert.strictEqual(q.offsetVal, 0);
done();
});

it('should be converted to a query proto successfully', function(done) {
var q = ds.createQuery(['Kind'])
.select(['name', 'count'])
Expand Down

0 comments on commit ffcf2d2

Please sign in to comment.