A practical guide to using Cloudflare D1, a SQLite-based SQL database for Cloudflare Workers. Covers creating a database with Wrangler, configuring bindings in wrangler.jsonc, managing schema changes with migrations, and querying data from a Worker using prepare/bind/all/run/first/batch APIs. Also explains when to use D1 versus R2 or KV.
Table of contents
Create a databaseSet up your schema with migrationsQuery from a WorkerUse parameters, alwaysInsert and updateMany statements at onceWhen D1 is the right call1.1K Impressions