Skip to content

Add descending order for getAll() and getAllKeys() #130

@nolanlawson

Description

@nolanlawson

In PouchDB we're implementing a "batched cursor" using getAll() and getAllKeys() (pouchdb/pouchdb#6060, pouchdb/pouchdb#6031). E.g. it can be used to paginate through an objectStore n records at a time, given a lower bound and optional upper bound.

Unfortunately we are only able to do this in ascending order, since in descending order the limit will always give us the first n records instead of the last n records. it would be nice if we could do something like:

objectStore.getAllKeys(keyRange, batchSize, 'prev').onsuccess = ...
objectStore.getAll(keyRange, batchSize, 'prev').onsuccess = ...

... where the batchSize would fetch the highest n records instead of the lowest. The downside of this method is that it's tricky to feature-detect unless you insert some dummy data and then try to fetch it, although maybe there's a more clever way.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions