-
Notifications
You must be signed in to change notification settings - Fork 785
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update the Neon and PlanetScale segments.
cut down content in the planetscale page
- Loading branch information
Showing
2 changed files
with
56 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,63 +49,81 @@ Several database providers enable the use of different protocols, such as HTTP a | |
|
||
#### Neon Serverless Driver | ||
|
||
Install the Prisma driver adapter for Neon, Neon serverless driver and `ws` packages: | ||
The [Neon serverless driver](https://neon.tech/docs/serverless/serverless-driver) provides a way of communicating with your database and executing queries over HTTP and WebSockets. | ||
|
||
```sh | ||
npm install @prisma/adapter-neon @neondatabase/serverless ws | ||
``` | ||
To use the Neon serverless driver with Prisma: | ||
|
||
Update your Prisma Client instance: | ||
1. Install the Prisma driver adapter for Neon, Neon serverless driver and `ws` packages: | ||
|
||
```ts | ||
import { Pool, neonConfig } from '@neondatabase/serverless' | ||
import { PrismaNeon } from '@prisma/adapter-neon' | ||
import { PrismaClient } from '@prisma/client' | ||
import dotenv from 'dotenv' | ||
import ws from 'ws' | ||
```sh | ||
npm install @prisma/adapter-neon @neondatabase/serverless ws | ||
``` | ||
|
||
dotenv.config() | ||
neonConfig.webSocketConstructor = ws | ||
const connectionString = `${process.env.DATABASE_URL}` | ||
2. Update your Prisma Client instance: | ||
|
||
const pool = new Pool({ connectionString }) | ||
const adapter = new PrismaNeon(pool) | ||
const prisma = new PrismaClient({ adapter }) | ||
``` | ||
```ts | ||
import { Pool, neonConfig } from '@neondatabase/serverless' | ||
import { PrismaNeon } from '@prisma/adapter-neon' | ||
import { PrismaClient } from '@prisma/client' | ||
import dotenv from 'dotenv' | ||
import ws from 'ws' | ||
|
||
dotenv.config() | ||
neonConfig.webSocketConstructor = ws | ||
const connectionString = `${process.env.DATABASE_URL}` | ||
|
||
const pool = new Pool({ connectionString }) | ||
const adapter = new PrismaNeon(pool) | ||
const prisma = new PrismaClient({ adapter }) | ||
``` | ||
|
||
We would appreciate your feedback on the Neon serverless driver adapter. Let us know what you think by leaving a comment in [this GitHub issue](https://github.com/prisma/prisma/discussions/21346). | ||
|
||
#### PlanetScale Serverless Driver | ||
|
||
Install the Prisma driver adapter for PlanetScale, PlanetScale serverless driver and undici packages: | ||
The [PlanetScale serverless driver](https://planetscale.com/docs/tutorials/planetscale-serverless-driver) provides a way of communicating with your database and executing queries over HTTP. | ||
|
||
```sh | ||
npm install @prisma/adapter-planetscale @planetscale/database undici | ||
``` | ||
To use the PlanetScale serverless driver with Prisma: | ||
|
||
Update your Prisma Client instance: | ||
1. Install the Prisma driver adapter for PlanetScale, PlanetScale serverless driver and undici packages: | ||
|
||
```ts | ||
import { connect } from '@planetscale/database' | ||
import { PrismaPlanetScale } from '@prisma/adapter-planetscale' | ||
import { PrismaClient } from '@prisma/client' | ||
import dotenv from 'dotenv' | ||
import { fetch as undiciFetch } from 'undici' | ||
```sh | ||
npm install @prisma/adapter-planetscale @planetscale/database undici | ||
``` | ||
|
||
dotenv.config() | ||
const connectionString = `${process.env.DATABASE_URL}` | ||
<Admonition> | ||
|
||
const connection = connect({ url: connectionString, fetch: undiciFetch }) | ||
const adapter = new PrismaPlanetScale(connection) | ||
const prisma = new PrismaClient({ adapter }) | ||
When using an older version of Node.js, you can provide a custom fetch function implementation. We recommend the `undici` package on which Node's built-in fetch is based. Node.js version 18 includes a built-in global `fetch` function. Node.js versions 18 and newer include `undici` and you don't have to install the package. See [System requirements](/reference/system-requirements) | ||
|
||
Ensure you update the host value in your connection string to `aws.connect.psdb.cloud`. You can learn more about this [here](https://planetscale.com/docs/tutorials/planetscale-serverless-driver#add-and-use-the-planetscale-serverless-driver-for-javascript-to-your-project). For example: | ||
|
||
```bash | ||
DATABASE_URL='mysql://johndoe:[email protected]/clear_nightsky?sslaccept=strict' | ||
``` | ||
|
||
</Admonition> | ||
|
||
2. Update your Prisma Client instance: | ||
|
||
```ts | ||
import { connect } from '@planetscale/database' | ||
import { PrismaPlanetScale } from '@prisma/adapter-planetscale' | ||
import { PrismaClient } from '@prisma/client' | ||
import dotenv from 'dotenv' | ||
import { fetch as undiciFetch } from 'undici' | ||
|
||
dotenv.config() | ||
const connectionString = `${process.env.DATABASE_URL}` | ||
|
||
const connection = connect({ url: connectionString, fetch: undiciFetch }) | ||
const adapter = new PrismaPlanetScale(connection) | ||
const prisma = new PrismaClient({ adapter }) | ||
``` | ||
|
||
We would appreciate your feedback on the PlanetScale serverless driver adapter. Let us know what you think by leaving a comment in [this GitHub issue](https://github.com/prisma/prisma/discussions/21347). | ||
|
||
### Database drivers | ||
|
||
{/* * TODO: intro note here */} | ||
|
||
#### Turso (Early Access) | ||
|
||
Install the Prisma driver adapter for LibSQL and LibSQL packages: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,71 +227,9 @@ For a more detailed example, see the [Getting Started guide for PlanetScale](/ge | |
|
||
## How to use the PlanetScale serverless driver with Prisma (Preview) | ||
|
||
The [PlanetScale serverless driver](https://planetscale.com/docs/tutorials/planetscale-serverless-driver) provides a way of communicating with your database and executing queries over HTTP. | ||
## How to use Neon's serverless driver with Prisma (Preview) | ||
|
||
You can use Prisma along with the PlanetScale serverless driver using a [driver adapter](/concepts/components/drivers#driver-adapters) <span class="concept"></span>. A driver adapter allows you to use a different database driver to communicate with your database from the default driver Prisma provides. | ||
|
||
<Admonition> | ||
|
||
This feature is available in Preview from Prisma versions 5.4.2 and later. | ||
|
||
</Admonition> | ||
|
||
To get started, enable the `driverAdapters` Preview feature flag: | ||
|
||
```prisma | ||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["driverAdapters"] | ||
} | ||
``` | ||
|
||
Generate Prisma Client: | ||
|
||
```sh | ||
npx prisma generate | ||
``` | ||
|
||
<Admonition> | ||
|
||
Ensure you update the host value in your connection string to `aws.connect.psdb.cloud`. You can learn more about this [here](https://planetscale.com/docs/tutorials/planetscale-serverless-driver#add-and-use-the-planetscale-serverless-driver-for-javascript-to-your-project). | ||
|
||
</Admonition> | ||
|
||
```bash | ||
DATABASE_URL='mysql://johndoe:[email protected]/clear_nightsky?sslaccept=strict' | ||
``` | ||
|
||
Install the Prisma adapter for PlanetScale, PlanetScale serverless driver and `undici` packages: | ||
|
||
```sh | ||
npm install @prisma/adapter-planetscale @planetscale/database undici | ||
``` | ||
|
||
<Admonition> | ||
|
||
When using an older version of Node.js, you can provide a custom fetch function implementation. We recommend the `undici` package on which Node's built-in fetch is based. Node.js version 18 includes a built-in global `fetch` function. Node.js versions 18 and newer include `undici` and you don't have to install the package. See [System requirements](/reference/system-requirements) | ||
|
||
</Admonition> | ||
|
||
Update your Prisma Client instance to use the PlanetScale serverless driver: | ||
|
||
```ts | ||
import { connect } from '@planetscale/database' | ||
import { PrismaPlanetScale } from '@prisma/adapter-planetscale' | ||
import { PrismaClient } from '@prisma/client' | ||
import dotenv from 'dotenv' | ||
import { fetch as undiciFetch } from 'undici' | ||
|
||
dotenv.config() | ||
const connectionString = `${process.env.DATABASE_URL}` | ||
|
||
const connection = connect({ url: connectionString, fetch: undiciFetch }) | ||
const adapter = new PrismaPlanetScale(connection) | ||
const prisma = new PrismaClient({ adapter }) | ||
``` | ||
|
||
You can then use Prisma Client as you normally would with full type-safety. | ||
To learn more on how you can use PlanetScale's serverless driver with Prisma, refer to [this page](/concepts/components/drivers#planetscale-serverless-driver). | ||
|
||
## More on using PlanetScale with Prisma | ||
|
||
|