-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f06f1a4
commit 28159ec
Showing
2 changed files
with
17 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,23 +172,31 @@ Setup an Accelerate connection string and proceed to the next step. | |
|
||
With the Accelerate connection string copied, you can replace the direct PostgreSQL connection string that you used to create the database schema in your `.env` file. | ||
|
||
Prisma Client for Prisma Accelerate does not read .env files by default, so you must also install dotenv-cli locally. | ||
|
||
### Steps | ||
|
||
1. Install the Prisma Accelerate client extension | ||
1. Install the `dotenv-cli`. | ||
|
||
``` | ||
npm install dotenv-cli | ||
``` | ||
|
||
2. Install the Prisma Accelerate client extension | ||
|
||
```bash | ||
npm install @prisma/extension-accelerate | ||
``` | ||
|
||
2. Add the Accelerate connection string to the `.env` file. Also, comment out the direct connection string. | ||
3. Add the Accelerate connection string to the `.env` file. Also, comment out the direct connection string. | ||
|
||
```bash file=.env | ||
DATABASE_URL="DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=__API_KEY__"" | ||
# Previous database connection | ||
# DATABASE_URL="postgres://..." | ||
``` | ||
|
||
3. Add the Prisma Accelerate extension to your Prisma Client | ||
4. Add the Prisma Accelerate extension to your Prisma Client | ||
|
||
```typescript | ||
import { PrismaClient } from './generated/client/deno/edge.ts' | ||
|
@@ -234,14 +242,14 @@ You can now start your application locally and test the creation of log entries. | |
|
||
3. Reload the page a few times.<br /><br />Every time you reload, the script generates a new log entry and the id of the current log entry increments. | ||
|
||
To check whether Accelerate is working, add the `withAccelerateInfo` at the end of your query. This returns an [`info`](/data-platform/accelerate/api-reference#return-type) object which provides additional information on the result of your query. | ||
To get more useful information on queries, add the `withAccelerateInfo` at the end of your query. This returns an [`info`](/data-platform/accelerate/api-reference#return-type) object which provides additional information on the result of your query. | ||
|
||
```ts | ||
import { serve } from 'https://deno.land/[email protected]/http/server.ts' | ||
import { PrismaClient } from './generated/client/deno/edge.ts' | ||
+import { withAccelerate } from '@prisma/extension-accelerate' | ||
import { withAccelerate } from '@prisma/extension-accelerate' | ||
|
||
+const prisma = new PrismaClient().$extends(withAccelerate()) | ||
const prisma = new PrismaClient().$extends(withAccelerate()) | ||
|
||
async function handler(request: Request) { | ||
const { data, info} = await prisma.log.create({ | ||
|