Skip to content

Commit 01df257

Browse files
author
Frank Natividad
committed
Add snapshot cursors sample
1 parent a971361 commit 01df257

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

firestore/cloud-client/snippets.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,19 @@ 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+
569+
return start_at_snapshot.limit(10).get()
570+
# [END fs_start_at_snapshot_query_cursor]
571+
572+
560573
def cursor_paginate():
561574
db = firestore.Client()
562575
# [START cursor_paginate]

firestore/cloud-client/snippets_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ def test_cursor_simple_end_at():
195195
snippets.cursor_simple_end_at()
196196

197197

198+
def test_snapshot_cursors():
199+
snippets.snapshot_cursors()
200+
201+
198202
def test_cursor_paginate():
199203
snippets.cursor_paginate()
200204

0 commit comments

Comments
 (0)