Skip to content

Commit

Permalink
update instructions for d1
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed Apr 2, 2024
1 parent 8164865 commit e6b19cd
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,9 @@ database_name = "__YOUR_D1_DATABASE_NAME__" # to be replaced
database_id = "__YOUR_D1_DATABASE_ID__" # to be replaced
```

Note that `__YOUR_D1_DATABASE_NAME__` and `__YOUR_D1_DATABASE_ID__` in the snippet above are placeholders that should be replaced with the database name and ID of your own D1 instance. If you weren't able to grab this ID from the terminal output, you can also find it in the Cloudflare Dashboard or by running `npx wrangler d1 list` and `npx wrangler d1 info __YOUR_D1_DATABASE_NAME__` in your terminal.
Note that `__YOUR_D1_DATABASE_NAME__` and `__YOUR_D1_DATABASE_ID__` in the snippet above are placeholders that should be replaced with the database name and ID of your own D1 instance.

If you weren't able to grab this ID from the terminal output, you can also find it in the Cloudflare Dashboard or by running `npx wrangler d1 list` and `npx wrangler d1 info __YOUR_D1_DATABASE_NAME__` in your terminal.

#### 4. Migrate your database schema (if applicable)

Expand Down Expand Up @@ -682,7 +684,7 @@ npx prisma generate

In order to query your database from the Worker using Prisma ORM, you need to:

1. Add the `DB` to the `Env` interface.
1. Add the `DB` binding to the `Env` interface. (Alternatively, you can run `npx wrangler types` to generate the `Env` type from the binding in a separate file called `worker-configuration.d.ts`.)
2. Instantiate `PrismaClient` using the `PrismaD1` driver adapter.
3. Send a query using Prisma Client and return the result.

Expand Down

0 comments on commit e6b19cd

Please sign in to comment.