You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/en/guides/backend/prisma-postgres.mdx
+24-16Lines changed: 24 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ import ReadMore from '~/components/ReadMore.astro';
13
13
14
14
[Prisma Postgres](https://www.prisma.io/) is a fully managed, serverless Postgres database built for modern web apps.
15
15
16
-
## Connect via Prisma ORM (Recommended)
16
+
## Connect with Prisma ORM (Recommended)
17
17
18
18
[Prisma ORM](https://www.prisma.io/orm) is the recommended way to connect to your Prisma Postgres database. It provides type-safe queries, migrations, and global performance.
19
19
@@ -25,14 +25,14 @@ import ReadMore from '~/components/ReadMore.astro';
25
25
Run the following commands to install the necessary Prisma dependencies:
You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database, like "My Astro Project."
@@ -47,12 +47,10 @@ Even if you don't need any specific data models yet, Prisma requires at least on
47
47
48
48
The following example defines a `Post` model as a placeholder. Add the model to your schema to get started. You can safely delete or replace it later with models that reflect your actual data.
49
49
50
-
Update the generator provider from `prisma-client-js` to `prisma-client` in your `prisma/schema.prisma` file:
Learn more about configuring your Prisma ORM setup in the [Prisma schema reference](https://www.prisma.io/docs/concepts/components/prisma-schema).
72
70
71
+
### Generate client
72
+
73
+
Run the following command to generate the Prisma Client from your schema:
74
+
75
+
```bash
76
+
npx prisma generate
77
+
```
78
+
73
79
### Generate migration files
74
80
75
81
Run the following command to create the database tables and generate the Prisma Client from your schema. This will also create a `prisma/migrations/` directory with migration history files.
@@ -83,12 +89,12 @@ npx prisma migrate dev --name init
83
89
Inside of `/src/lib`, create a `prisma.ts` file. This file will initialize and export your Prisma Client instance so you can query your database throughout your Astro project.
It is best practice to handle queries in an API route. For more information on how to use Prisma ORM in your Astro project, see the [Astro + Prisma ORM Guide](https://www.prisma.io/docs/guides/astro).
129
135
130
-
## Direct TCP connection
131
-
To connect to Prisma Postgres via direct TCP, you can create a direct connection string in your Prisma Console. This allows you to connect any other ORM, database library, or tool of your choice.
136
+
## Connect with Other ORMs and Libraries
137
+
138
+
You can connect to Prisma Postgres via direct TCP using any other ORM, database library, or tool of your choice. Create a direct connection string in your Prisma Console to get started.
132
139
133
140
### Prerequisites
141
+
- An Astro project with an adapter installed to enable [on-demand rendering (SSR)](/en/guides/on-demand-rendering/).
134
142
- A [Prisma Postgres](https://pris.ly/ppg) database with a TCP enabled connection string
135
143
136
144
### Install dependencies
137
145
138
-
This example will make a direct TCP connection using [`pg`, a PostgreSQL client for Node.js](https://github.com/brianc/node-postgres).
146
+
This example uses [`pg`, a PostgreSQL client for Node.js](https://github.com/brianc/node-postgres) to make a direct TCP connection.
139
147
140
148
Run the following command to install the `pg` package:
0 commit comments