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
You should receive the following output on your terminal:
86
80
87
-
```sh
81
+
```txt
88
82
✅ Successfully created DB 'orange-demo-db' in region EEUR
89
83
Created your database using D1's new storage backend. The new storage backend is not yet recommended for production workloads, but backs up your data via
90
84
point-in-time restore.
@@ -102,7 +96,7 @@ point-in-time restore.
102
96
103
97
You now have a D1 database in your Cloudflare account with a binding to your Cloudflare Worker.
104
98
105
-
Copy the `json` snippet from the command output and paste it into your `wrangler.jsonc` file. Your `wrangler.jsonc` file should look similar to the following:
99
+
Copy the JSON snippet from the command output and paste it into your `wrangler.jsonc` file. Your `wrangler.jsonc` file should look similar to the following:
106
100
107
101
<WranglerConfig>
108
102
@@ -127,15 +121,15 @@ Copy the `json` snippet from the command output and paste it into your `wrangler
127
121
128
122
</WranglerConfig>
129
123
130
-
`<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 orange-demo-db` in your terminal.
124
+
Replace `<YOUR_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 orange-demo-db` in your terminal.
131
125
132
126
Next, create a database table in the database to send queries to D1 using Orange ORM.
133
127
134
128
### 4. Create a table in the database
135
129
136
-
D1 has a [migration system](/d1/reference/migrations), and in the following steps, you will use D1's migration system to create and run a migration against your database.
130
+
D1 has a [migration system](/d1/reference/migrations/), and in the following steps, you will use D1's migration system to create and run a migration against your database.
137
131
138
-
1. First, create a new migration using `wrangler`:
CREATEUNIQUE INDEX "User_email_key" ON"User"("email");
165
159
```
166
160
167
-
168
161
You now need to use the `wrangler d1 migrations apply` command to send this SQL statement to D1. This command accepts two flags:
169
162
170
163
-`--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.
171
164
-`--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.
172
165
173
-
In this tutorial, you will first test the Worker locally, then deploy your Worker afterwards.
166
+
In this tutorial, you will first test the Worker locally, then deploy your Worker.
To query your database from the Worker using Orange ORM, you need to:
204
197
205
-
1. Create a `src/map.ts` with the following code:
198
+
1. Create a `src/map.ts`file with the following code:
206
199
207
200
```ts
208
201
importorangefrom'orange-orm';
@@ -246,7 +239,7 @@ export default {
246
239
npm run dev
247
240
```
248
241
249
-
2. Open your browser at [`http://localhost:8787`](http://localhost:8787/) to check the result of the database query. You should see the following `json` block:
242
+
2. Open your browser at [`http://localhost:8787`](http://localhost:8787/) to check the result of the database query. You should see the following JSON block:
0 commit comments