Reputation: 434
My app will use IndexedDB via Dexie, and I would like to use composite keys. (Dexie keys are the same as for IndexedDB.)
What types of keys are supported by Dexie and IndexedDB, and how are they ordered?
Upvotes: 1
Views: 483
Reputation: 434
From https://w3c.github.io/IndexedDB/#key-type
" . . . negative infinity is the lowest possible value for a key. Number keys are less than date keys. Date keys are less than string keys. String keys are less than binary keys. Binary keys are less than array keys. There is no highest possible key value. This is because an array of any candidate highest key followed by another key is even higher. Members of binary keys are compared as unsigned byte values (in the range 0 to 255 inclusive) rather than signed byte values (in the range -128 to 127 inclusive)."
String comparisons give the same results as JavaScript's < operator and sorting of arrays of strings.
If one array key a1 is a prefix of array key a2, in other words they are the same up to the length of a1, but a2 is longer, key a1 is less than key a2.
Upvotes: 1