indexingindexeddbpartialcomposite

IndexedDB composite index partial match


I can't find an answer to this anywhere.

I have an indexeddb composite index of a group id and a time, which I use to sort.

let tmp_CREATEDTIMEindex = texts.index('GROUP_ID, CREATEDTIME');

This works great, except I need to result to reflect only the group id, not the time. How do I get a result from a match on just the group id?

To clarify, this returns one record: let request = tmp_CREATEDTIMEindex.getAll(['someid', 'August, 25 2022 06:52:02']);

I need it to return all records. let request = tmp_CREATEDTIMEindex.getAll(['someid', '*']);


Solution

  • You can use a key range:

    let range = IDBKeyRange.bound(['someid'], ['someid\x00'], true, true);
    let request = tmp_CREATEDTIMEindex.getAll(range);