Three posts, three layers. Each one can stand alone; read in order they compound into the full working picture.
Setting up D1 with Drizzle in Hono — wiring it up.
wrangler.jsonc, Drizzle config, the first migration, a basic Hono handler, Drizzle Studio against the local Miniflare SQLite, pushing to production.Drizzle with Cloudflare D1 — the everyday usage guide — the read, write, and soft-delete patterns you reach for every day. Dynamic
wherecomposition, joins with projected fields,RETURNING, audit columns, and thesqltemplate.D1 has no transactions — using
client.batch()for multi-step writes — the first real gotcha. D1 has noBEGIN/COMMIT;client.batch([...])is the answer, and it has four subtle rules worth writing down.
The examples in parts 2 and 3 come from DuitGee — a fund-based expense tracker I’m building on this stack. Real schema names, real handlers, real production code.