-
Notifications
You must be signed in to change notification settings - Fork 856
Update ORM docs #7253
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
Closed
AmanVarshney01
wants to merge
3
commits into
prisma-7
from
dc-5032-docs-update-orm-docs-to-use-prisma-config
Closed
Update ORM docs #7253
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,14 +25,32 @@ To connect to a PostgreSQL database server, you need to configure a [`datasource | |||||||||||||||||||||
| ```prisma file=schema.prisma | ||||||||||||||||||||||
| datasource db { | ||||||||||||||||||||||
| provider = "postgresql" | ||||||||||||||||||||||
| url = env("DATABASE_URL") | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| The database connection URL is configured in `prisma.config.ts`: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```ts file=prisma.config.ts | ||||||||||||||||||||||
| import { defineConfig, env } from 'prisma/config' | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export default defineConfig({ | ||||||||||||||||||||||
| schema: 'prisma/schema.prisma', | ||||||||||||||||||||||
| datasource: { | ||||||||||||||||||||||
| url: env('DATABASE_URL'), | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| }) | ||||||||||||||||||||||
| ``` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| <Admonition type="info"> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| **Note**: When using Prisma CLI commands, environment variables are not automatically loaded. You'll need to use a package like `dotenv` to load environment variables from a `.env` file, or ensure your environment variables are set in your shell. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| </Admonition> | ||||||||||||||||||||||
|
Comment on lines
+44
to
+48
Contributor
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.
Suggested change
@AmanVarshney01 can you update the components to use the more modern components while making changes in the PR? |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| The fields passed to the `datasource` block are: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| - `provider`: Specifies the `postgresql` data source connector. | ||||||||||||||||||||||
| - `url`: Specifies the [connection URL](#connection-url) for the PostgreSQL database server. In this case, an [environment variable is used](/orm/prisma-schema/overview#accessing-environment-variables-from-the-schema) to provide the connection URL. | ||||||||||||||||||||||
| - The `url` field is configured in `prisma.config.ts` and specifies the [connection URL](#connection-url) for the PostgreSQL database server. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ## Using the `node-postgres` driver | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -56,7 +74,7 @@ Now, when you instantiate Prisma Client, you need to pass an instance of Prisma | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| ```ts | ||||||||||||||||||||||
| import { PrismaPg } from '@prisma/adapter-pg' | ||||||||||||||||||||||
| import { PrismaClient } from '@prisma/client' | ||||||||||||||||||||||
| import { PrismaClient } from '../prisma/generated/client' | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const connectionString = `${process.env.DATABASE_URL}` | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@AmanVarshney01 let's add the import 'dotenv/config' to all the config files.