Sync API — no await, direct returns

The in-memory backend supports a synchronous mirror of every CRUD method: createSync, readSync, updateSync, deleteSync, listSync, countSync. No Promises, no microtasks — useful for tight loops, tests, and synchronous event handlers where you can't await.

Checking backend…

How it works

flowchart LR
    A["db.create(...)"] --> P[Promise] --> V1[record]
    S["db.createSync(...)"] --> V2[record]
    S -. throws on
persistent backend .-> X[Error] A -. works on
any backend .-> ALL[memory · IDB · encrypted] style A fill:#fff3e0,stroke:#ef6c00 style S fill:#e0f2f1,stroke:#00897b style X fill:#ffcdd2,stroke:#c62828 style ALL fill:#e8f5e9,stroke:#2e7d32

Try it — a three-step tour

  1. Click Seed 20 records. 20 createSync calls land in the users entity.
  2. Click listSync (all), listSync (filter age > 50), and listSync (sort age desc). Each returns the array immediately — no await in the handler code.
  3. Click Performance comparison. Runs 1000 sync creates vs 1000 async creates side by side and shows the ratio.

Sync CRUD

Queries

countSync

0

listSync

Quick actions

Records

IDDataActions

Automated test suite

Run all tests runs 11 steps and reports pass/fail:

  1. isMemoryBackend() is true
  2. createSync returns id + _version=1
  3. readSync returns matching fields
  4. updateSync bumps _version and merges
  5. deleteSync removes the row
  6. Seed 20, listSync returns all 20
  7. listSync with filter returns subset
  8. listSync with desc sort is monotonic
  9. countSync without filter returns 20
  10. countSync with filter matches listSync length
  11. Sync vs async create × 1000 — prints both timings
Click the button to run.

Log