Getting Started

persistence-drizzle

A typed Drizzle ORM database over any SQLite driver, with one lock, safe transactions and checked migrations.

persistence-drizzle is a Drizzle ORM database over any SQLite driver, for an app that owns one SQLite connection and has more than one writer: a Capacitor app on a phone, a browser app on sql.js, a Node test suite.

Why use it?

ProblemWhat persistence-drizzle does
Two writers interleave statements on one connectionOne first-in, first-out lock in front of every statement
Drizzle's db.transaction over a proxy lets other writers run inside itIt is refused; transaction(fn) holds the lock from BEGIN IMMEDIATE to COMMIT
A transaction handle kept after commit writes outside the lockThe handle rejects once its transaction has ended
A newer build wrote the database, or a shipped migration was editedOpening refuses (unknown-applied, drift) instead of corrupting data
A resolved write is lost on reload where storage is an exportWrites are flushed before they resolve
Importing a pasted save can pollute prototypes or exhaust memoryA bounded, sanitised envelope reader that never throws
Unit tests need a different database path than the appThe same Drizzle path runs on node:sqlite

Start with Getting started, then read the guides on migrations, transactions and the Capacitor driver. The API reference has the signatures and the architecture notes the invariants behind them.