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.

3m read timeFrom flaviocopes.com
Post cover image
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 call
1.1K Impressions