-
Notifications
You must be signed in to change notification settings - Fork 876
docs: Fix outdated instructions #7457
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughDocumentation update to Prisma Client initialization guidance, adding installation and usage of the PostgreSQL adapter package ( Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@content/200-orm/050-overview/100-introduction/100-what-is-prisma.mdx`:
- Around line 185-190: The example passes process.env.DATABASE_URL directly to
PrismaPg and can fail TypeScript checks because process.env.DATABASE_URL is
string | undefined; define a connectionString constant (e.g., const
connectionString = `${process.env.DATABASE_URL}`) and pass that to new
PrismaPg(...) and to new PrismaClient(...) where the adapter is set so the types
are satisfied and the docs remain consistent; update both occurrences around the
PrismaPg/PrismaClient examples to use the connectionString constant instead of
process.env.DATABASE_URL directly.
| import { PrismaClient } from './generated/client' | ||
| import { PrismaPg } from '@prisma/adapter-pg'; | ||
|
|
||
| const prisma = new PrismaClient() | ||
| const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL }); | ||
| const prisma = new PrismaClient({ adapter }) | ||
| ``` |
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.
Use a connectionString constant to keep TS types happy and align doc conventions.
process.env.DATABASE_URL is string | undefined in TS, so the current example can fail type-checking. Defining a connectionString constant (with a template literal) both satisfies TS and keeps adapter examples consistent across docs. Based on learnings, ...
🔧 Suggested update for both tabs
-import { PrismaPg } from '@prisma/adapter-pg';
-
-const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
+import { PrismaPg } from '@prisma/adapter-pg'
+
+const connectionString = `${process.env.DATABASE_URL}`
+const adapter = new PrismaPg({ connectionString })
const prisma = new PrismaClient({ adapter })-const { PrismaPg } = require('@prisma/adapter-pg')
-
-const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
+const { PrismaPg } = require('@prisma/adapter-pg')
+
+const connectionString = `${process.env.DATABASE_URL}`
+const adapter = new PrismaPg({ connectionString })
const prisma = new PrismaClient({ adapter })PrismaPg adapter connectionString TypeScript example Prisma docs
Also applies to: 196-200
🤖 Prompt for AI Agents
In `@content/200-orm/050-overview/100-introduction/100-what-is-prisma.mdx` around
lines 185 - 190, The example passes process.env.DATABASE_URL directly to
PrismaPg and can fail TypeScript checks because process.env.DATABASE_URL is
string | undefined; define a connectionString constant (e.g., const
connectionString = `${process.env.DATABASE_URL}`) and pass that to new
PrismaPg(...) and to new PrismaClient(...) where the adapter is set so the types
are satisfied and the docs remain consistent; update both occurrences around the
PrismaPg/PrismaClient examples to use the connectionString constant instead of
process.env.DATABASE_URL directly.
Fixes outdated instructions to be in line with recent changes (https://www.prisma.io/docs/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-7#driver-adapters-and-client-instantiation).
Closes prisma/prisma#28670
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.