feat(database): support the optional startAt key #821
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
npm install
,npm run build
, andnpm test
run successfully? yesDescription
This PR introduces support for the optional
key
parameter that can be passed to the SDK'sstartAt
method. According to the SDK documentation, the parameter is "allowed if ordering by child, value, or priority".There was some discussion in the linked (and closed) issue regarding the
key
parameter only being supported and useful when ordering by priority, but the documentation suggests that it is also supported - bystartAt
- when ordering by child and value. Indeed, were it not to be supported, it would not be possible to reliably page through lists that are ordered by child when there are large numbers of items with the same child value. This is an issue that I currently have with an implementation of aFirebaseListObservable
-based infinite list.There is a plunk here that demonstrates the use of
key
with the SDK to page when ordering by child.Code sample
The
key
parameter is really only useful when paging through results, so this code sample is contrived and not particularly sensible: