File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -557,6 +557,22 @@ def cursor_simple_end_at():
557557 return query_end_at
558558
559559
560+ def snapshot_cursors ():
561+ db = firestore .Client ()
562+ # [START fs_start_at_snapshot_query_cursor]
563+ doc_ref = db .collection (u'cities' ).document (u'SF' )
564+
565+ snapshot = doc_ref .get ()
566+ start_at_snapshot = db .collection (
567+ u'cities' ).order_by (u'population' ).start_at (snapshot )
568+ # [END fs_start_at_snapshot_query_cursor]
569+ results = start_at_snapshot .limit (10 ).get ()
570+ for doc in results :
571+ print ('{}' .format (doc .id ))
572+
573+ return results
574+
575+
560576def cursor_paginate ():
561577 db = firestore .Client ()
562578 # [START cursor_paginate]
Original file line number Diff line number Diff line change @@ -195,6 +195,14 @@ def test_cursor_simple_end_at():
195195 snippets .cursor_simple_end_at ()
196196
197197
198+ def test_snapshot_cursors (capsys ):
199+ snippets .snapshot_cursors ()
200+ out , _ = capsys .readouterr ()
201+ assert "SF" in out
202+ assert "TOK" in out
203+ assert "BJ" in out
204+
205+
198206def test_cursor_paginate ():
199207 snippets .cursor_paginate ()
200208
You can’t perform that action at this time.
0 commit comments