MQDB WebAssembly examples Loading…

Twelve self-contained pages, each demonstrating one feature with a guided tour, a how-it-works diagram, and an automated test suite you can run in the browser.

Each page is a complete HTML file backed by pkg/mqdb_wasm.js — no build step needed beyond wasm-pack build --target web.

New here? Start at the top

  1. Basic CRUD — create / read / update / delete and the _version field.
  2. Filtering — filter operators, sort, pagination, projection.
  3. Schema — typed fields, required + default.
  4. Constraints — UNIQUE, NOT NULL, FK cascade/restrict.
  5. Subscriptions — reactive change events, consumer groups.
  6. Persistent then Encrypted — IndexedDB and AES-GCM at rest.
Core data operations
start here

Basic CRUD

Create / read / update / delete and merge semantics. Auto-assigned ids and _version bumps on every write.

query

Filtering & sorting

eq/ne/gt/lt/gte/lte/glob/null filters plus sort, pagination, projection. Multi-filter is AND.

query

Count

count(opts) returns just the matching row count, without loading the rows.

query

Cursor

Streaming iteration — nextItem() / nextBatch() over a filter result without materializing the array.

Integrity
shape

Schema validation

Declare field types, required fields, and default values. MQDB validates every write.

rules

Constraints

UNIQUE, NOT NULL, FOREIGN KEY with CASCADE / RESTRICT / SET NULL on delete.

join

Relationships

Declare posts.author → users once; read with includes to get the joined record.

Reactive
events

Subscriptions

Register a callback and get every matching create/update/delete. Shared subscriptions route broadcast or load-balanced.

Storage backends
idb

Persistent (IndexedDB)

Data survives reloads. Toggle between in-memory and IndexedDB modes and watch the difference.

aes-gcm

Encrypted (AES-GCM)

Passphrase-derived key, per-record encryption. Lock/unlock flow with live ciphertext view.

Advanced
api style

Sync API

createSync/listSync/… no-await mirror of CRUD for the memory backend. Includes perf comparison.

mqtt routing

Execute (topic routing)

Everything MQDB does, addressed by MQTT-style topic — the same surface the networked broker uses.

Getting started locally

# Build the WASM package
cd crates/mqdb-wasm
wasm-pack build --target web

# Serve the examples
cd examples
python3 -m http.server 8080

# Open http://localhost:8080/