Re: [w3c/IndexedDB] Add descending order for getAll() and getAllKeys() (#130)

SteveBeckerMSFT left a comment (w3c/IndexedDB#130)

Thanks for the discussion!  @nolanlawson , in your [comment above](https://github.com/w3c/IndexedDB/issues/130#issuecomment-2856841012), do you have any examples where more robust query feature detection will be needed?  What "more sophisticated IDB query options" do you have in mind?

I'm prototyping option 1 in Chromium, which will use getAllRecords() as feature detection for getAll()/getAllKeys() direction support through the options dictionary.  I updated [the getAllRecords() explainer](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/IndexedDbGetAllEntries/explainer.md#adding-direction-to-getall-and-getallkeys) to outline this plan.  

As mentioned in the explainer, supporting the IDBGetAllOptions dictionary with getAll()/getAllKeys() introduces compat risk.  In particular, some inputs will no longer throw exceptions.  For example:

```js
// `getAll()` No longer throws a "DataError" since the input object is parsed as an `IDBGetAllOptions` dictionary.
object_store.getAll( { test: 'object' } ); 
```

We could potentially reduce compat risk by making one of the IDBGetAllOptions dictionary entries required (like direction maybe).  However, requiring direction seems unnatural and maybe not needed since these exception indicate programmer error.

Additionally, some getAll()/getAllKey() [input objects might be valid IndexedDB keys](https://w3c.github.io/IndexedDB/#key-construct), which includes Dates, Arrays, and ArrayBuffers.  We'll need to avoid parsing these types as IDBGetAllOptions dictionaries to maintain existing behavior.

While this proposal has some quirks, I believe it will meet developer expectations while addressing this issue.  

As always, feedback is very welcome!

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

Message ID: <w3c/IndexedDB/issues/130/2963970168@github.com>

Received on Wednesday, 11 June 2025 19:49:23 UTC