Re: [w3c/IndexedDB] Future: Support Tuples as compound keys (Issue #390)

> Assuming the [Record & Tuple](https://tc39.es/proposal-record-tuple/) proposal lands in ECMAScript, we should support specifying [composite keys](https://github.com/w3c/IndexedDB/issues/360) with tuples. Namely things like this would be expected to work:
> 
> ```js
> // tuples and arrays are equally valid ways to specify composite keys
> assert(indexedDB.cmp([1,2,3], #[1,2,3]) === 0);
> 
> // tuples and arrays are interchangeable where keys are used
> store.put('value1', #[1,2,3]); 
> store.put('value2', [4,5,6]); 
> store.get([1,2,3]).onsuccess = e => { assert(e.target.result === 'value1'; };
> store.get(#[4,5,6]).onsuccess = e => { assert(e.target.result === 'value2'; };
> 
> // but IndexedDB operations that return composite keys to script still produce arrays
> store.put('value', #[1,2,3]).onsuccess = e => { let key = e.target.result; assert(Array.isArray(key)); };
> ```
> 
> I believe this would only require normative changes in https://w3c.github.io/IndexedDB/#convert-value-to-key and an non-normative changes in https://w3c.github.io/IndexedDB/#key-construct
> 
> 



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

Message ID: <w3c/IndexedDB/issues/390/1402818022@github.com>

Received on Tuesday, 24 January 2023 23:20:01 UTC