Skip to content

Commit 0a526bc

Browse files
shiyuhang0ti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#20794
Signed-off-by: ti-chi-bot <[email protected]>
1 parent 709e783 commit 0a526bc

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

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

+23-8
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,7 +56,22 @@ const adapter = new PrismaTiDBCloud(connection);
5456
const prisma = new PrismaClient({ adapter });
5557
```
5658

59+
<<<<<<< HEAD
5760
Then, queries from Prisma Client can be sent to the TiDB Cloud Serverless Driver for processing.
61+
=======
62+
For `@tidbcloud/prisma-adapter` v6.6.0 or a later version:
63+
64+
```js
65+
import { PrismaTiDBCloud } from '@tidbcloud/prisma-adapter';
66+
import { PrismaClient } from '@prisma/client';
67+
68+
// Initialize Prisma Client
69+
const adapter = new PrismaTiDBCloud({ url: ${DATABASE_URL} });
70+
const prisma = new PrismaClient({ adapter });
71+
```
72+
73+
Then, queries from Prisma Client can be sent to the TiDB Cloud serverless driver for processing.
74+
>>>>>>> 194df99145 (update prisma-adapter (#20794))
5875
5976
## Use the Prisma adapter in Node.js environments
6077

@@ -93,12 +110,12 @@ To complete this tutorial, you need the following:
93110
{
94111
"type": "module",
95112
"dependencies": {
96-
"@prisma/client": "^5.5.2",
97-
"@tidbcloud/prisma-adapter": "^5.5.2",
98-
"@tidbcloud/serverless": "^0.0.7"
113+
"@prisma/client": "^6.6.0",
114+
"@tidbcloud/prisma-adapter": "^6.6.0",
115+
"@tidbcloud/serverless": "^0.1.0"
99116
},
100117
"devDependencies": {
101-
"prisma": "^5.5.2"
118+
"prisma": "^6.6.0"
102119
}
103120
}
104121
```
@@ -187,7 +204,6 @@ To complete this tutorial, you need the following:
187204
1. Create a file named `hello-word.js` and add the following code to initialize Prisma Client:
188205
189206
```js
190-
import { connect } from '@tidbcloud/serverless';
191207
import { PrismaTiDBCloud } from '@tidbcloud/prisma-adapter';
192208
import { PrismaClient } from '@prisma/client';
193209
import dotenv from 'dotenv';
@@ -197,8 +213,7 @@ To complete this tutorial, you need the following:
197213
const connectionString = `${process.env.DATABASE_URL}`;
198214
199215
// Initialize Prisma Client
200-
const connection = connect({ url: connectionString });
201-
const adapter = new PrismaTiDBCloud(connection);
216+
const adapter = new PrismaTiDBCloud({ url: connectionString });
202217
const prisma = new PrismaClient({ adapter });
203218
```
204219

0 commit comments

Comments
 (0)