CKTIS / JavaScript
IDBKeyRange — IndexedDB key ranges
IDBKeyRange describes a range of keys for IndexedDB queries. The only method selects one key, while bound defines an interval whose endpoints can optionally be excluded.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
IDBKeyRange.only(value)
IDBKeyRange.bound(lower, upper)
IDBKeyRange.bound(lower, upper, lowerOpen)
IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen)
range.includes(key)IDBKeyRange describes keys, not record values. Pass it to an object store's or index's openCursor(); for an index, the range applies to index keys. Create ranges through static methods, not new IDBKeyRange().
IDBKeyRange.only(value) covers exactly one key. IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen) creates an interval: both flags default to false, including the endpoints; true excludes the corresponding endpoint. includes(key) tests membership without opening a database.
An invalid key, such as NaN, causes DataError. Reversed bounds, or equal bounds with either endpoint excluded, do likewise. IndexedDB key ordering applies, not comparison of textual representations.
This is a Web API, not an ECMAScript feature; the specification exposes it in Window and Worker. Having Node 24 does not establish support. Check availability in the target browser; the sources are not a current compatibility table.
Examples
const exact = IDBKeyRange.only(20);
const interval = IDBKeyRange.bound(10, 30, false, true);
const keys = [5, 10, 20, 30, 40];
console.log(JSON.stringify(keys.filter(key => exact.includes(key))));
console.log(JSON.stringify(keys.filter(key => interval.includes(key))));Result
[20] [10,20]
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.