An example Kysely project using kysely-d1 and Cloudflare D1.
First, create a D1 database:
npm run create-db
Take note of the name and UUID of the database.
Then, update the binding in wrangler.toml
to use your D1 database.
[[ d1_databases ]]
binding = "DB" # i.e. available in your Worker on env.DB
database_name = "kysely-test"
database_id = "<YOUR ID>"
Then, run the migration script:
npm run setup
After setup, run the project locally:
npm run start