Something went wrong. Try again.
Something went wrong. Try again.
Files
Verified signature Signed by sakurakat.systems SHA256:PzSOv36xVw2a388m6yyJHS+RFsv+YT7NhCzPPo6ovT4 Click to copy SHA
Verified signature Signed by sakurakat.systems SHA256:PzSOv36xVw2a388m6yyJHS+RFsv+YT7NhCzPPo6ovT4 Click to copy SHA
Verified signature Signed by sakurakat.systems SHA256:PzSOv36xVw2a388m6yyJHS+RFsv+YT7NhCzPPo6ovT4 Click to copy SHA
- TypeScript 100%
README.md
Worker + D1 Database #
D1 is Cloudflare's native serverless SQL database (docs). This project demonstrates using a Worker with a D1 binding to execute a SQL statement. A simple frontend displays the result of this query:
SELECT * FROM comments LIMIT 3;
The D1 database is initialized with a comments table and this data:
INSERT INTO comments (author, content)
VALUES
('Kristian', 'Congrats!'),
('Serena', 'Great job!'),
('Max', 'Keep up the good work!')
;
Important
When using C3 to create this project, select "no" when it asks if you want to deploy. You need to follow this project's setup steps before deploying.
Getting Started #
Outside of this repo, you can start a new project with this template using C3 (the create-cloudflare CLI):
npm create cloudflare@latest -- --template=cloudflare/templates/d1-template
A live public deployment of this template is available at https://d1-template.templates.workers.dev
Setup Steps #
- Install the project dependencies with a package manager of your choice:
npm install - Create a D1 database with the name "d1-template-database":
...and update thenpx wrangler d1 create d1-template-databasedatabase_idfield inwrangler.jsonwith the new database ID. - Run the following db migration to initialize the database (notice the
migrationsdirectory in this project):npx wrangler d1 migrations apply --remote d1-template-database - Deploy the project!
npx wrangler deploy