You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browser version: Version 100.0.4896.75 (Official Build) (arm64)
Firebase SDK version: 9.6.10
Firebase Product: firestore
[REQUIRED] Describe the problem
When using endBefore(cursor) and limitToLast(n), the snapshot contains n-1 documents
Steps to reproduce:
Add some data to a collection with timestamp
query, orderBy timestamp, limit 3
load next page
load prev page with endBefore and limitToLast
snapshot contains 1 less doc
Relevant Code:
constapp=initializeApp({//});constdb=getFirestore(app);constref=collection(db,'tests');// add test dataconstbatch=writeBatch(db);['2022-04-01','2022-04-02','2022-04-03','2022-04-04','2022-04-05','2022-04-06',].forEach((date)=>{batch.set(doc(ref,date),{timestamp: newDate(date),
date,});});awaitbatch.commit();constpage1=awaitgetDocs(query(ref,orderBy('timestamp'),limit(3))).then((snap)=>{console.log('page 1',snap.docs.map((doc)=>doc.data().date));returnsnap.docs;});// get next pageconstpage2=awaitgetDocs(query(ref,orderBy('timestamp'),limit(3),startAfter(page1[page1.length-1]))).then((snap)=>{console.log('page 2',snap.docs.map((doc)=>doc.data().date));returnsnap.docs;});// get prev pageconstshouldBePage1=awaitgetDocs(query(ref,orderBy('timestamp'),limitToLast(3),endBefore(page2[0]))).then((snap)=>{console.log('should be page 1',snap.docs.map((doc)=>doc.data().date));returnsnap.docs;});/*outputpage 1 ['2022-04-01', '2022-04-02', '2022-04-03']page 2 ['2022-04-04', '2022-04-05', '2022-04-06']should be page1 ['2022-04-02', '2022-04-03']*/
if I use the regular limit, the size of snapshot is correct
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
When using endBefore(cursor) and limitToLast(n), the snapshot contains n-1 documents
Steps to reproduce:
endBefore
andlimitToLast
Relevant Code:
if I use the regular limit, the size of snapshot is correct
The text was updated successfully, but these errors were encountered: