0

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', '*']);

1 Answer 1

1

You can use a key range:

let range = IDBKeyRange.bound(['someid'], ['someid\x00'], true, true);
let request = tmp_CREATEDTIMEindex.getAll(range);
  • ['someid'] sorts before any other composite key starting with 'someid'
  • ['someid\x00'] sorts after any other composite key starting with 'someid'
  • the true, true arguments exclude those keys specifically from the results
Sign up to request clarification or add additional context in comments.

1 Comment

Joshua Bell genius, many thanks! Works perfectly!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.