Skip to content

update prisma-adapter #20794

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

Merged
merged 3 commits into from
Apr 18, 2025
Merged
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
27 changes: 19 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`.

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

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

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 prisma = new PrismaClient({ adapter });
```

Then, queries from Prisma Client can be sent to the TiDB Cloud serverless driver for processing.

## Use the Prisma adapter in Node.js environments
Expand Down Expand Up @@ -93,12 +106,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 +200,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';
import { PrismaClient } from '@prisma/client';
import dotenv from 'dotenv';
Expand All @@ -197,8 +209,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