jakearchibald / idb

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

(IDBPObjectStore | IDBPIndex).iterateKeys(..args) #112

Open scottohara opened 5 years ago

scottohara commented 5 years ago

Just as .iterate() is a convenience for .openCursor() (avoids the need for an if (cursor) ... check for when the cursor returns no results),

...should there also be an equivalent .iterateKeys() as a similar convenience for .openKeyCursor()?

Currently to async-iterate over the keys of a store or index, it seems like the only option is:

let cursor = await store.openKeyCursor();
if (cursor) for await (const cursor of cursor) {
  // use cursor.key here...
}

For symmetry, it would seem like this may also be useful:

for await (const cursor of store.iterateKeys()) {
  // use cursor.key here...
}
jakearchibald commented 5 years ago

Yeah, that seems fair