Skip to content

Commit 589c8ab

Browse files
committed
Add missing previous function in pagination snippet
1 parent 509769a commit 589c8ab

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

firestore-next/test.firestore.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,17 @@ describe("firestore", () => {
10881088
orderBy("population"),
10891089
startAfter(lastVisible),
10901090
limit(25));
1091+
1092+
// Get the first visible document
1093+
const firstVisible = documentSnapshots.docs[0];
1094+
console.log("first", firstVisible);
1095+
1096+
// Construct a new query starting at this document,
1097+
// get the previous 25 cities.
1098+
const previous = query(collection(db, "cities"),
1099+
orderBy("population"),
1100+
endBefore(lastVisible),
1101+
limitToLast(25));
10911102
// [END paginate]
10921103
});
10931104
});

snippets/firestore-next/test-firestore/paginate.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,15 @@ const next = query(collection(db, "cities"),
2121
orderBy("population"),
2222
startAfter(lastVisible),
2323
limit(25));
24+
25+
// Get the first visible document
26+
const firstVisible = documentSnapshots.docs[0];
27+
console.log("first", firstVisible);
28+
29+
// Construct a new query starting at this document,
30+
// get the previous 25 cities.
31+
const previous = query(collection(db, "cities"),
32+
orderBy("population"),
33+
endBefore(lastVisible),
34+
limitToLast(25));
2435
// [END paginate_modular]

0 commit comments

Comments
 (0)