Re: [w3c/IndexedDB] Allow delete() on index (#68)

I'd like to +1 this feature. My use case is that I had a little helper function like this:

```js
function deleteAll (store, storeOrIndex, keyRange) {
  storeOrIndex.getAllKeys(keyRange).onsuccess = e => {
    for (const result of e.target.result) {
      store.delete(result)
    }
  }
}
```

Then I realized that [`IDBObjectStore.delete()`](https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/delete) accepts a key range. Great – I can remove this code!

Except then I noticed the `storeOrIndex` variable, and that there's no way to delete multiple records using a key range on an index.

My precise use case is that [I'm deleting data from an object store based on a foreign key](https://github.com/nolanlawson/pinafore/blob/21678ec78efd7871b98a64bb00ada08704d2d0d8/src/routes/_database/cleanup.js#L38-L55). (E.g. delete a post, and delete all replies to that post.) This, along with the "delete everything with `item.timestamp` less than some value," both seem like common use cases to me.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/68#issuecomment-904275602

Received on Tuesday, 24 August 2021 02:39:10 UTC