Skip to content

Commit 194df99

Browse files
authored
update prisma-adapter (#20794)
1 parent 4df40e6 commit 194df99

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

tidb-cloud/serverless-driver-prisma-example.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ datasource db {
4141

4242
## Initialize Prisma Client
4343

44-
Before using Prisma Client, you need to initialize it with `@tidbcloud/prisma-adapter`. For example:
44+
Before using Prisma Client, you need to initialize it with `@tidbcloud/prisma-adapter`.
45+
46+
For `@tidbcloud/prisma-adapter` earlier than v6.6.0:
4547

4648
```js
4749
import { connect } from '@tidbcloud/serverless';
@@ -54,6 +56,17 @@ const adapter = new PrismaTiDBCloud(connection);
5456
const prisma = new PrismaClient({ adapter });
5557
```
5658

59+
For `@tidbcloud/prisma-adapter` v6.6.0 or a later version:
60+
61+
```js
62+
import { PrismaTiDBCloud } from '@tidbcloud/prisma-adapter';
63+
import { PrismaClient } from '@prisma/client';
64+
65+
// Initialize Prisma Client
66+
const adapter = new PrismaTiDBCloud({ url: ${DATABASE_URL} });
67+
const prisma = new PrismaClient({ adapter });
68+
```
69+
5770
Then, queries from Prisma Client can be sent to the TiDB Cloud serverless driver for processing.
5871

5972
## Use the Prisma adapter in Node.js environments
@@ -93,12 +106,12 @@ To complete this tutorial, you need the following:
93106
{
94107
"type": "module",
95108
"dependencies": {
96-
"@prisma/client": "^5.5.2",
97-
"@tidbcloud/prisma-adapter": "^5.5.2",
98-
"@tidbcloud/serverless": "^0.0.7"
109+
"@prisma/client": "^6.6.0",
110+
"@tidbcloud/prisma-adapter": "^6.6.0",
111+
"@tidbcloud/serverless": "^0.1.0"
99112
},
100113
"devDependencies": {
101-
"prisma": "^5.5.2"
114+
"prisma": "^6.6.0"
102115
}
103116
}
104117
```
@@ -187,7 +200,6 @@ To complete this tutorial, you need the following:
187200
1. Create a file named `hello-word.js` and add the following code to initialize Prisma Client:
188201
189202
```js
190-
import { connect } from '@tidbcloud/serverless';
191203
import { PrismaTiDBCloud } from '@tidbcloud/prisma-adapter';
192204
import { PrismaClient } from '@prisma/client';
193205
import dotenv from 'dotenv';
@@ -197,8 +209,7 @@ To complete this tutorial, you need the following:
197209
const connectionString = `${process.env.DATABASE_URL}`;
198210
199211
// Initialize Prisma Client
200-
const connection = connect({ url: connectionString });
201-
const adapter = new PrismaTiDBCloud(connection);
212+
const adapter = new PrismaTiDBCloud({ url: connectionString });
202213
const prisma = new PrismaClient({ adapter });
203214
```
204215

0 commit comments

Comments
 (0)