Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor pagination helpers do not follow descending ordering #101

Open
kimroen opened this issue Feb 5, 2021 · 0 comments
Open

Cursor pagination helpers do not follow descending ordering #101

kimroen opened this issue Feb 5, 2021 · 0 comments

Comments

@kimroen
Copy link
Contributor

kimroen commented Feb 5, 2021

The pagination helpers on a query such as startAt, endAt, startAfter and endAfter do not respect the ordering direction.

An example using startAfter:

const firestore = new MockFirestore().firestore();

await firestore.collection('my-collection').doc('first-document').set({ score: 1 });
await firestore.collection('my-collection').doc('second-document').set({ score: 2 });
await firestore.collection('my-collection').doc('third-document').set({ score: 3 });

// This should return second-document, then first-document, but it does not
await firestore
  .collection('my-collection')
  .orderBy('score', 'desc')
  .startAfter(3)
  .get();

In filterByCursor, the value is compared using >:

} if (cursor === 'startAfter') {
return data[id][prop] > value;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant