diff --git a/README.md b/README.md index 8c5254a6b27..60f2b6590c6 100644 --- a/README.md +++ b/README.md @@ -210,9 +210,9 @@ Pagination allows you to set an offset, limit and starting cursor to a query. ~~~~ js var q = ds.createQuery('Company') - .offset(100) // start from 101th result - .limit(10) // return only 10 results .start(cursorToken); // continue to retrieve results from the given cursor. + .offset(100) // start from the 101th result after start cursor. + .limit(10) // return only 10 results ~~~~ #### Allocating IDs (ID generation) diff --git a/lib/datastore/index.js b/lib/datastore/index.js index c64c3099cf7..46ab7ca3313 100644 --- a/lib/datastore/index.js +++ b/lib/datastore/index.js @@ -219,7 +219,7 @@ Transaction.prototype.runQuery = function(q, opt_callback) { } var nextQuery = null; if (resp.batch.endCursor && resp.batch.endCursor != q.startVal) { - nextQuery = q.start(resp.batch.endCursor); + nextQuery = q.start(resp.batch.endCursor).offset(0); } opt_callback(null, entity.formatArray(resp.batch.entityResults), nextQuery); }); diff --git a/lib/datastore/query.js b/lib/datastore/query.js index ac7b7f5a7a8..01230d31484 100644 --- a/lib/datastore/query.js +++ b/lib/datastore/query.js @@ -76,7 +76,6 @@ 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; } diff --git a/test/datastore.query.js b/test/datastore.query.js index 1b72f33c481..33d370a59be 100644 --- a/test/datastore.query.js +++ b/test/datastore.query.js @@ -112,13 +112,6 @@ 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'])