Persistent storage — survives reloads

Open a database with Database.openPersistent(name) and every write is mirrored to IndexedDB. Close the tab, reload, quit the browser — your data is still there next time. The in-memory backend, in contrast, vanishes with the page.

How it works

flowchart LR
    M["new Database()"] --> MB[In-memory map]
    P["openPersistent('name')"] --> IDB[(IndexedDB)]
    W1["db.create(...)"] --> MB
    W2["db.create(...)"] --> IDB
    R1[Page reload] --> MB2[Empty — data gone]
    R2[Page reload] --> IDB
    IDB --> MB3[Data restored]
    style MB fill:#fff3e0,stroke:#ef6c00
    style IDB fill:#e3f2fd,stroke:#1565c0
    style MB2 fill:#ffcdd2,stroke:#c62828
    style MB3 fill:#c8e6c9,stroke:#2e7d32
                

Try it — a three-step tour

  1. The page starts in persistent mode. Click +1 Increment a few times — the counter is stored in IndexedDB.
  2. Click Reload page to test persistence. The counter value stays where you left it.
  3. Switch to In-memory mode, increment the counter, reload. The counter resets — nothing was persisted.

Persistence counter

Stored in the counter entity of the current database. Reload the page to test whether it survives.

Storage mode

In-memory fast, no I/O, ephemeral
IndexedDB survives reloads

IndexedDB — data persists across page reloads.

Data

Records

IDData

IndexedDB inspector

Look at what MQDB has actually written to IndexedDB — keys and JSON payloads.

Click "Inspect IndexedDB" to view raw data

Automated test suite

Run all tests runs 6 steps; the last one tests round-tripping the counter so you can then reload the page to confirm persistence.

  1. Create a record in persistent storage
  2. Read it back
  3. Verify IndexedDB actually contains bytes (run the inspector)
  4. Update — new value reads back
  5. Delete — read throws
  6. Counter increments by 10 end-to-end
Click the button to run.

Log