You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
binding = "DB"# i.e. available in your Worker on env.DB
131
134
database_name = "prisma-demo-db"
132
-
database_id = "__YOUR_D1_DATABASE_ID__"
135
+
database_id = "<D1_DATABASE_ID>"
133
136
```
134
137
135
138
</WranglerConfig>
136
139
137
-
`__YOUR_D1_DATABASE_ID__` should be replaced with the database ID of your D1 instance. If you were not able to fetch this ID from the terminal output, you can also find it in the [Cloudflare dashboard](https://dash.cloudflare.com/), or by running `npx wrangler d1 info prisma-demo-db` in your terminal.
140
+
Replace `<D1_DATABASE_ID>` with the database ID of your D1 instance. If you were not able to fetch this ID from the terminal output, you can also find it in the [Cloudflare dashboard](https://dash.cloudflare.com/), or by running `npx wrangler d1 info prisma-demo-db` in your terminal.
138
141
139
142
Next, you will create a database table in the database to send queries to D1 using Prisma ORM.
140
143
@@ -154,10 +157,11 @@ Answer `yes` to creating a new folder called `migrations`.
154
157
155
158
The command has now created a new directory called `migrations` and an empty file called `0001_create_user_table.sql` inside of it:
156
159
157
-
```
158
-
migrations/
159
-
└── 0001_create_user_table.sql
160
-
```
160
+
<FileTree>
161
+
- prisma-d1-example
162
+
- migrations
163
+
-**0001_create_user_table.sql**
164
+
</FileTree>
161
165
162
166
Next, you need to add the SQL statement that will create a `User` table to that file.
163
167
@@ -198,7 +202,9 @@ You now need to use the `wrangler d1 migrations apply` command to send this SQL
198
202
-`--local`: Executes the statement against a _local_ version of D1. This local version of D1 is a SQLite database file that will be located in the `.wrangler/state` directory of your project. Use this approach when you want to develop and test your Worker on your local machine. Refer to [Local development](/d1/best-practices/local-development/) to learn more.
199
203
-`--remote`: Executes the statement against your _remote_ version of D1. This version is used by your _deployed_ Cloudflare Workers. Refer to [Remote development](/d1/best-practices/remote-development/) to learn more.
200
204
201
-
In this tutorial, you will do local and remote development. You will test the Worker locally and deploy your Worker afterwards. Open your terminal, and run both commands:
205
+
In this tutorial, you will do both local and remote development. You will test the Worker locally, then deploy your Worker afterwards.
If you receive an error to the effect of `Unknown arguments: (\email\,, \name\)...`, you may need to escape the double quotes with backticks (`) instead of backslashes (\\).
237
+
:::
238
+
229
239
### 5. Query your database from the Worker
230
240
231
241
To query your database from the Worker using Prisma ORM, you need to:
0 commit comments