Firestore supports pagination cursors such as startAt, endAt, and startAfter, which are recommended over using offsets due to performance and cost implications. The current implementation of Fireorm does not fully support these cursors, and there is a need to develop a clean API to handle pagination efficiently. For more information on why offsets are discouraged and how cursors work, refer to the Firestore best practices and Firestore query cursors documentation.
Steps to Reproduce
Attempt to use startAfter or other pagination cursors with the current Fireorm implementation.
Note the lack of support and limitations in extending the existing repository classes.
Expected Behavior
A new or improved API within Fireorm that supports Firestore pagination cursors, allowing for efficient and cost-effective data retrieval without relying on offsets.
Actual Behavior
Current Fireorm implementation does not support Firestore pagination cursors effectively, leading to performance issues and additional costs when using offsets.
Acceptance Criteria
Develop functions in the query builder similar to Firestore's standard library functions (startAfter, startAt, etc.).
Update the query builder to return an object containing both results and cursor information:
{
results: T[], // results of query
cursor: DocumentRef // document ref of last result
}
Ensure the new functions provide a clean and efficient API for pagination.
Consider the impact on the return type of queries and manage any breaking changes effectively.
Additional Context
October 8, 2019: Initial issue opened to discuss implementation of pagination cursors.
June 9, 2020: Comment by @dmythro about the lack of current support and a suggestion to extend repository classes for a quick fix.
December 7, 2020: @garviand suggested adding functions to the query builder or updating the execute function to include cursor information.
December 9, 2020: Mention of a proof of concept and further exploration of possible implementations.
February 18, 2021: @garviand noted issues with stringifying arrays and suggested limitations in practical use.
April 22, 2021, August 25, 2021: Inquiries about updates, with no active development on this feature.
Description
Firestore supports pagination cursors such as
startAt
,endAt
, andstartAfter
, which are recommended over using offsets due to performance and cost implications. The current implementation of Fireorm does not fully support these cursors, and there is a need to develop a clean API to handle pagination efficiently. For more information on why offsets are discouraged and how cursors work, refer to the Firestore best practices and Firestore query cursors documentation.Steps to Reproduce
startAfter
or other pagination cursors with the current Fireorm implementation.Expected Behavior
A new or improved API within Fireorm that supports Firestore pagination cursors, allowing for efficient and cost-effective data retrieval without relying on offsets.
Actual Behavior
Current Fireorm implementation does not support Firestore pagination cursors effectively, leading to performance issues and additional costs when using offsets.
Acceptance Criteria
startAfter
,startAt
, etc.).Additional Context
Original Issue