Interface IndexedDbAdapterOptions

Configuration for IndexedDB adapter.

interface IndexedDbAdapterOptions {
    dbName?: string;
    storeName?: string;
    autoSave?: boolean;
    saveIntervalMs?: number;
    sqlJsConfig?: any;
    durability?: IndexedDbDurability;
    crossTab?: boolean | IndexedDbCrossTabOptions;
    segment?: string;
    memoryOnly?: boolean;
}

Properties

dbName?: string

IndexedDB database name (default: 'app-db')

storeName?: string

IndexedDB object store name (default: 'sqliteDb')

autoSave?: boolean

Auto-save to IndexedDB on a timer (default: true)

saveIntervalMs?: number

Save interval in milliseconds for batched writes (default: 5000)

sqlJsConfig?: any

sql.js configuration (e.g., locateFile for wasm)

durability?: IndexedDbDurability

When a write is stored in IndexedDB.

  • 'interval', the default: the auto-save tick stores the writes made since the last save, every saveIntervalMs; flush() and close() store them at once. A write can be lost when the page goes before the next tick.
  • 'commit': run(), exec(), a write through all() or get() (INSERT ... RETURNING) and transaction() resolve once their write is in IndexedDB, and reject when IndexedDB refuses it (the write stays in the database and the next save stores it, unless crossTab's rollbackRefusedSaves gives it up). Each save writes the whole database image, so batch many writes in one transaction(). While a transaction a caller opened with BEGIN is open, nothing can be saved: its statements resolve at once, and its rows are stored when its COMMIT resolves.
crossTab?: boolean | IndexedDbCrossTabOptions

Keeps the writes of two tabs of the site that open the same database. Each tab holds the whole database in memory and writes it back whole, so without this the tab that saves last overwrites the other's writes.

With crossTab, every statement and transaction runs under a Web Lock on the database, on the newest stored image (a tab reloads it when another has saved), and is stored before the lock is let go: durability is 'commit' whatever it says. Where the browser has no Web Locks (Safari before 15.4, an insecure origin, Lockdown Mode), the version stamp stored beside the image keeps both tabs' writes alone: a statement that finds another tab saved first runs again on the newer image, and a transaction() is refused with IndexedDbConflictError, storing nothing, for its caller to run again. The adapter says once when it runs without Web Locks.

A transaction begun with BEGIN through run() or exec() cannot be held across tabs: it is rolled back and refused. Use transaction().

segment?: string

A database of its own: the segment is appended to dbName (app-db becomes app-db-agentos). Lower-case letters, digits and underscores.

memoryOnly?: boolean

Keeps the database in memory alone: IndexedDB is never opened, nothing is stored, and capabilities carries no persistence. durability reads 'interval' and crossTab is off, since there is nothing to store or to share. For a browser that refuses IndexedDB (a private window, a blocked storage setting), where open() would otherwise reject.