-
Notifications
You must be signed in to change notification settings - Fork 692
update prisma-adapter (#20794) #20801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release-cloud
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -41,7 +41,9 @@ datasource db { | |||||||||||||||||||
|
||||||||||||||||||||
## Initialize Prisma Client | ||||||||||||||||||||
|
||||||||||||||||||||
Before using Prisma Client, you need to initialize it with `@tidbcloud/prisma-adapter`. For example: | ||||||||||||||||||||
Before using Prisma Client, you need to initialize it with `@tidbcloud/prisma-adapter`. | ||||||||||||||||||||
|
||||||||||||||||||||
For `@tidbcloud/prisma-adapter` earlier than v6.6.0: | ||||||||||||||||||||
|
||||||||||||||||||||
```js | ||||||||||||||||||||
import { connect } from '@tidbcloud/serverless'; | ||||||||||||||||||||
|
@@ -54,7 +56,22 @@ const adapter = new PrismaTiDBCloud(connection); | |||||||||||||||||||
const prisma = new PrismaClient({ adapter }); | ||||||||||||||||||||
``` | ||||||||||||||||||||
|
||||||||||||||||||||
<<<<<<< HEAD | ||||||||||||||||||||
Then, queries from Prisma Client can be sent to the TiDB Cloud Serverless Driver for processing. | ||||||||||||||||||||
======= | ||||||||||||||||||||
For `@tidbcloud/prisma-adapter` v6.6.0 or a later version: | ||||||||||||||||||||
|
||||||||||||||||||||
```js | ||||||||||||||||||||
import { PrismaTiDBCloud } from '@tidbcloud/prisma-adapter'; | ||||||||||||||||||||
import { PrismaClient } from '@prisma/client'; | ||||||||||||||||||||
|
||||||||||||||||||||
// Initialize Prisma Client | ||||||||||||||||||||
const adapter = new PrismaTiDBCloud({ url: ${DATABASE_URL} }); | ||||||||||||||||||||
Comment on lines
+62
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||
const prisma = new PrismaClient({ adapter }); | ||||||||||||||||||||
``` | ||||||||||||||||||||
|
||||||||||||||||||||
Then, queries from Prisma Client can be sent to the TiDB Cloud serverless driver for processing. | ||||||||||||||||||||
>>>>>>> 194df99145 (update prisma-adapter (#20794)) | ||||||||||||||||||||
|
||||||||||||||||||||
## Use the Prisma adapter in Node.js environments | ||||||||||||||||||||
|
||||||||||||||||||||
|
@@ -93,12 +110,12 @@ To complete this tutorial, you need the following: | |||||||||||||||||||
{ | ||||||||||||||||||||
"type": "module", | ||||||||||||||||||||
"dependencies": { | ||||||||||||||||||||
"@prisma/client": "^5.5.2", | ||||||||||||||||||||
"@tidbcloud/prisma-adapter": "^5.5.2", | ||||||||||||||||||||
"@tidbcloud/serverless": "^0.0.7" | ||||||||||||||||||||
"@prisma/client": "^6.6.0", | ||||||||||||||||||||
"@tidbcloud/prisma-adapter": "^6.6.0", | ||||||||||||||||||||
"@tidbcloud/serverless": "^0.1.0" | ||||||||||||||||||||
}, | ||||||||||||||||||||
"devDependencies": { | ||||||||||||||||||||
"prisma": "^5.5.2" | ||||||||||||||||||||
"prisma": "^6.6.0" | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
``` | ||||||||||||||||||||
|
@@ -187,7 +204,6 @@ To complete this tutorial, you need the following: | |||||||||||||||||||
1. Create a file named `hello-word.js` and add the following code to initialize Prisma Client: | ||||||||||||||||||||
|
||||||||||||||||||||
```js | ||||||||||||||||||||
import { connect } from '@tidbcloud/serverless'; | ||||||||||||||||||||
import { PrismaTiDBCloud } from '@tidbcloud/prisma-adapter'; | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
import { PrismaClient } from '@prisma/client'; | ||||||||||||||||||||
import dotenv from 'dotenv'; | ||||||||||||||||||||
|
@@ -197,8 +213,7 @@ To complete this tutorial, you need the following: | |||||||||||||||||||
const connectionString = `${process.env.DATABASE_URL}`; | ||||||||||||||||||||
|
||||||||||||||||||||
// Initialize Prisma Client | ||||||||||||||||||||
const connection = connect({ url: connectionString }); | ||||||||||||||||||||
const adapter = new PrismaTiDBCloud(connection); | ||||||||||||||||||||
const adapter = new PrismaTiDBCloud({ url: connectionString }); | ||||||||||||||||||||
const prisma = new PrismaClient({ adapter }); | ||||||||||||||||||||
``` | ||||||||||||||||||||
|
||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a brief explanation of why different versions of
@tidbcloud/prisma-adapter
require different initialization methods. This would provide more context for users and help them understand the changes.