Skip to content

Commit 0bc7682

Browse files
committed
Adding doc snippet for paging with cursors.
1 parent 04751e5 commit 0bc7682

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

datastore/google/cloud/datastore/client.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,23 @@ def query(self, **kwargs):
464464
>>> for entity in query_iter:
465465
... do_something(entity)
466466
467+
or manually page through results
468+
469+
.. code-block:: python
470+
471+
>>> query_iter = query.fetch(start_cursor='2mdd223i944')
472+
>>> pages = query_iter.pages
473+
>>>
474+
>>> page1 = next(pages)
475+
>>> entities1 = list(page1)
476+
>>> query_iter.next_page_token
477+
'abc-some-cursor'
478+
>>>
479+
>>> page2 = next(pages)
480+
>>> entities2 = list(page2)
481+
>>> query_iter.next_page_token is None
482+
True
483+
467484
Under the hood this is doing:
468485
469486
.. code-block:: python

0 commit comments

Comments
 (0)