jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.29k stars 353 forks source link

Typing for openCursor and openKeyCursor should allow null for the query parameter. #211

Closed cmlenz closed 3 years ago

cmlenz commented 3 years ago

The typings for the IDBPObjectStore and IDBPIndex methods openCursor and openKeyCursor should allow null for the query parameter.

This is needed for example to iterate over all values in the store in descending order:

const cursor = myObjectStore.openCursor(null, 'prev');

The TypeScript lib.dom.d.ts also explicitly mentions this in the doc comment:

Opens a cursor over the records matching query, ordered by direction. If query is null, all records in index are matched.

I think the idb typings should be updated accordingly.

jakearchibald commented 3 years ago

Thanks for reporting this. It will be fixed in the next release.

cmlenz commented 3 years ago

Great, thanks for the quick fix!