OptionalresetTablesOnUpgrade?: booleanwhen version triggers an upgrade (i.e. it
exceeds whatever is on disk), drop and recreate every table in tables instead of only
creating the ones that don't exist yet. For a host accepting "a version bump clears local
data" as its migration story — no copy, no marker table, just IndexedDB's own version
tracking making this a one-time event. Irrelevant on a brand-new database (drop is a no-op
on a table that doesn't exist).
Optionaltables?: string[]tables to create when version triggers an upgrade
Optionalversion?: numberopen at this version, creating tables on upgrade.
Omit to open at whatever version already exists.
OptionalversionMigrate?: (STRUCTURAL version-upgrade hook, run INSIDE the versionchange transaction when version triggers
an upgrade — after the default tables create/reset. Use it for changes that can only happen in
an upgrade: create/delete a store, or copy rows between stores via ctx.transaction. oldVersion
(0 on a fresh database) lets the host branch per version step. In-place record rewrites do NOT
need this — use map() afterward. Runs only on the configured-version open, not on the
incremental bumps createTable/dropTable do.
StaticDELETESentinel a map(table, fn) callback returns to DELETE the current row (returning a value updates
it; returning undefined leaves it unchanged). A Symbol so it can never collide with a real
stored value.
The version this instance was CONSTRUCTED with (null when omitted). A plain noun — it is what
the host asked for, not what is on disk; await db.version() is the latter, and the two diverge
as soon as createTable/dropTable bumps it.
Delete every row in table, keeping the table itself (contrast clearAll(), which clears every table).
Clear every row from every existing store in ONE transaction — a full data wipe that keeps the
schema and the version. This is the "refresh completely" for a key-value store: to start over you
clear and re-add, no schema teardown needed. (Contrast clear(table) for one store, and
destroy() which deletes the whole database.)
the tables that were cleared
Drop the in-memory connection. Data persists; the next call reopens.
Create a table. Returns false if it already existed. Bumps the DB version.
Delete one row.
Delete the entire database.
Drop a table. Returns false if it did not exist. Bumps the DB version.
→ the stored value, or undefined if absent. (Absent and broken are distinguishable: a broken read REJECTS rather than resolving undefined, unlike the old io/db.js.)
True if key exists (distinguishes a stored undefined from a missing row).
List rows. { keys: true } returns just the keys (cheap — no values deserialized), which is
what a picker listing filenames wants. range is an optional IDBKeyRange.
Optionalopts: { keys?: boolean; range?: IDBKeyRange } = {}Iterate table's key→value pairs IN KEY ORDER, transforming each row in place — the general
iterate/transform primitive, and the DATA-migration tool (rename/add/drop a field, re-shape a
value, prune rows) that helps a version update WITHOUT a schema upgrade: values are verbatim and
keys are out-of-line, so a record's shape is not part of the schema. Runs in ONE readwrite
transaction. To read without changing anything, return undefined every time.
fn(key, value) returns:
• a value → update the row (skipped when strictly === value, so an unchanged row costs nothing),
• Storage.DELETE → delete the row,
• undefined → leave the row untouched (a safe default: a callback that forgets to return does
nothing rather than wiping data).
how many rows were updated or deleted
Store value under key, verbatim.
anything structured-cloneable, stored exactly as given
the key
A handle scoped to one table, so row ops read as verbs on the table itself
(storage.table('userFiles').put(key, value)) instead of repeating the table name as an
argument to the db-level Storage instance on every call. Pure sugar — each method delegates
to the matching Storage method below with table bound; no separate transaction logic, no
state of its own (cheap to create, nothing to dispose).
Table names currently in the database.
This database's CURRENT on-disk version, or null if it does not exist yet.
Safe to call before opening — it never creates the database and never triggers an upgrade. When a
connection is already open its live db.version is authoritative (and needs no
indexedDB.databases() support); otherwise it reads the origin's database list.
StaticdatabasesEvery IndexedDB database in this origin, with its current version.
Wraps indexedDB.databases(), which is unavailable in a few older engines — there it throws
rather than reporting "no databases", since an empty list would be indistinguishable from a real
answer and could tempt a host into destroying live data.
StaticexistsDoes a database of this name already exist in this origin?
database name — REQUIRED; the host owns the schema