简体   繁体   中英

What types of keys are allowed in IndexedDB, and how are they ordered?

My app will use IndexedDB via Dexie, and I would like to use composite keys. The Dexie documentation is pretty good, but does not cover the use of IndexedDB database keys.

What types of keys are supported by IndexedDB, and how are they ordered?

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)."

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM