Skip to content

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

Open
wants to merge 1 commit into
base: release-cloud
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions tidb-cloud/serverless-driver-prisma-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.


For `@tidbcloud/prisma-adapter` earlier than v6.6.0:

```js
import { connect } from '@tidbcloud/serverless';
Expand All @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ${DATABASE_URL} syntax looks a bit odd in the code block. It might be clearer to use a placeholder like YOUR_DATABASE_URL and explain that users should replace it with their actual database URL. This will prevent confusion about whether the dollar sign and curly braces are part of the actual code.

Suggested change
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} });
const adapter = new PrismaTiDBCloud({ url: YOUR_DATABASE_URL });

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

Expand Down Expand Up @@ -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"
}
}
```
Expand Down Expand Up @@ -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';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a comment explaining why the connect import is removed here. This will help users understand the change and avoid confusion.

import { PrismaClient } from '@prisma/client';
import dotenv from 'dotenv';
Expand All @@ -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 });
```

Expand Down