# IndexedDB

A browser-native key-value store with indexes, transactions, and cursors. It's the main option for storing large amounts of structured data client-side — localStorage caps out at ~5 MB, while IndexedDB can hold hundreds of megabytes or more depending on the browser and available disk.

IndexedDB stores JavaScript objects (not rows) in object stores (not tables). Each object store can have multiple indexes for efficient lookup. Transactions are required for all reads and writes, and the API is entirely asynchronous — originally callback-based, though most modern code wraps it in promises.

## Indexes and multiEntry

An index maps a key path on stored objects to a B-tree for fast lookup. The `multiEntry` flag is particularly useful: when set on an index over an array field, IndexedDB creates a separate index entry for each array element rather than treating the whole array as a single key. This effectively gives you an [[inverted-index]] — each term in the array points back to the containing document.

[[full-text-search-indexeddb]] uses this to build full-text search: store pre-tokenized terms as an array field, index it with `multiEntry: true`, then query by individual terms.

## What it doesn't have

No SQL, no full-text search, no joins, no aggregation. If you need any of these, you build them yourself or use something like sql.js (SQLite compiled to WebAssembly). The [[full-text-search-indexeddb]] article shows that for simple token-match search, the native index capabilities are sufficient without reaching for heavier tools.

## Where it shows up

Offline-first web apps like [[borogove]] use it as their primary data store. Service workers use it for caching structured data. Libraries like Dexie.js and idb provide friendlier APIs on top of the raw IndexedDB interface.
