Indexable Type
The following javascript types are possible to index:
- number
- Date
- string
- ArrayBuffer
- Typed arrays (Uint8Array, Float32Array, ..., etc)
- Arrays of (strings, numbers, Dates, ArrayBuffer, Typed array) or a mix of those.
Note that all other types are non-indexable, including:
- boolean
- undefined
- Object
- null
Type order
Index keys of different types can be compared against each other. The following order applies:
- -Infinity
- number
- Infinity
- Date
- string
- TypedArray and ArrayBuffer
- Arrays
Lowest and Highest possible keys
- The lowest possible value is
-Infinity. Dexie has an alias for it:Dexie.minKey. - There is theoretically no highest possible value as Array may contain Arrays of Arrays etc... But Dexie provide an alias for the practical maximum key
Dexie.maxKey = [[]](an array of an array).
See also
Sample
const db = new Dexie('testdb');
db.version(1).stores({
foo: 'id,bar'
});
db.foo.put({id: null}); // fails with DataError because null is not indexable.
db.foo.put({id: 1, bar: null}); // succeeds but fails silently to be indexed by "bar" index.
db.foo.where('bar').equals(undefined).toArray(); // Fails with DataError as undefined is not indexable.