Skip to content

Commit 5bd3043

Browse files
authored
chore(prisma): cleanup adapter jsdoc (#10862)
1 parent 5136b3f commit 5bd3043

File tree

2 files changed

+4
-215
lines changed

2 files changed

+4
-215
lines changed

docs/pages/getting-started/adapters/prisma.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ DATABASE_URL=postgres://postgres:[email protected]:5432/db
2727

2828
### Configuration
2929

30-
<Callout>
31-
We recommend using version `@prisma/[email protected]` or above if using middleware
32-
or any other edge runtime(s).
30+
<Callout type="warning">
31+
We recommend using version `@prisma/[email protected]` or above if using
32+
middleware or any other edge runtime(s). See [edge
33+
compatibility](#edge-compatibility) below for more information.
3334
</Callout>
3435

3536
<Code>

packages/adapter-prisma/src/index.ts

Lines changed: 0 additions & 212 deletions
Original file line numberDiff line numberDiff line change
@@ -24,218 +24,6 @@ import type {
2424
AdapterUser,
2525
} from "@auth/core/adapters"
2626

27-
/**
28-
* ## Setup
29-
*
30-
* Add this adapter to your `auth.ts` Auth.js configuration object:
31-
*
32-
* ```js title="auth.ts"
33-
* import NextAuth from "next-auth"
34-
* import Google from "next-auth/providers/google"
35-
* import { PrismaAdapter } from "@auth/prisma-adapter"
36-
* import { PrismaClient } from "@prisma/client"
37-
*
38-
* const prisma = new PrismaClient()
39-
*
40-
* export const { handlers, auth, signIn, signOut } = NextAuth({
41-
* adapter: PrismaAdapter(prisma),
42-
* providers: [
43-
* Google,
44-
* ],
45-
* })
46-
* ```
47-
*
48-
* ### Create the Prisma schema from scratch
49-
*
50-
* You need to use at least Prisma 2.26.0. Create a schema file in `prisma/schema.prisma` similar to this one:
51-
*
52-
* > This schema is adapted for use in Prisma and based upon our main [schema](https://authjs.dev/reference/core/adapters#models)
53-
*
54-
* ```json title="schema.prisma"
55-
* datasource db {
56-
* provider = "postgresql"
57-
* url = env("DATABASE_URL")
58-
* shadowDatabaseUrl = env("SHADOW_DATABASE_URL") // Only needed when using a cloud provider that doesn't support the creation of new databases, like Heroku. Learn more: https://pris.ly/d/migrate-shadow
59-
* }
60-
*
61-
* generator client {
62-
* provider = "prisma-client-js"
63-
* previewFeatures = ["referentialActions"] // You won't need this in Prisma 3.X or higher.
64-
* }
65-
*
66-
* model Account {
67-
* id String @id @default(cuid())
68-
* userId String
69-
* type String
70-
* provider String
71-
* providerAccountId String
72-
* refresh_token String? @db.Text
73-
* access_token String? @db.Text
74-
* expires_at Int?
75-
* token_type String?
76-
* scope String?
77-
* id_token String? @db.Text
78-
* session_state String?
79-
*
80-
* user User @relation(fields: [userId], references: [id], onDelete: Cascade)
81-
*
82-
* @@unique([provider, providerAccountId])
83-
* }
84-
*
85-
* model Session {
86-
* id String @id @default(cuid())
87-
* sessionToken String @unique
88-
* userId String
89-
* expires DateTime
90-
* user User @relation(fields: [userId], references: [id], onDelete: Cascade)
91-
* }
92-
*
93-
* model User {
94-
* id String @id @default(cuid())
95-
* name String?
96-
* email String? @unique
97-
* emailVerified DateTime?
98-
* image String?
99-
* accounts Account[]
100-
* sessions Session[]
101-
* }
102-
*
103-
* model VerificationToken {
104-
* identifier String
105-
* token String @unique
106-
* expires DateTime
107-
*
108-
* @@unique([identifier, token])
109-
* }
110-
* ```
111-
*
112-
* :::note
113-
* When using the MySQL connector for Prisma, the [Prisma `String` type](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string) gets mapped to `varchar(191)` which may not be long enough to store fields such as `id_token` in the `Account` model. This can be avoided by explicitly using the `Text` type with `@db.Text`.
114-
* :::
115-
*
116-
*
117-
* ### Create the Prisma schema with `prisma migrate`
118-
*
119-
* This will create an SQL migration file and execute it:
120-
*
121-
* ```
122-
* npx prisma migrate dev
123-
* ```
124-
*
125-
* Note that you will need to specify your database connection string in the environment variable `DATABASE_URL`. You can do this by setting it in a `.env` file at the root of your project.
126-
*
127-
* To learn more about [Prisma Migrate](https://www.prisma.io/migrate), check out the [Migrate docs](https://www.prisma.io/docs/concepts/components/prisma-migrate).
128-
*
129-
* ### Generating the Prisma Client
130-
*
131-
* Once you have saved your schema, use the Prisma CLI to generate the Prisma Client:
132-
*
133-
* ```
134-
* npx prisma generate
135-
* ```
136-
*
137-
* To configure your database to use the new schema (i.e. create tables and columns) use the `prisma migrate` command:
138-
*
139-
* ```
140-
* npx prisma migrate dev
141-
* ```
142-
*
143-
* ### MongoDB support
144-
*
145-
* Prisma supports MongoDB, and so does Auth.js. Following the instructions of the [Prisma documentation](https://www.prisma.io/docs/concepts/database-connectors/mongodb) on the MongoDB connector, things you have to change are:
146-
*
147-
* 1. Make sure that the id fields are mapped correctly
148-
*
149-
* ```prisma
150-
* id String @id @default(auto()) @map("_id") @db.ObjectId
151-
* ```
152-
*
153-
* 2. The Native database type attribute to `@db.String` from `@db.Text` and userId to `@db.ObjectId`.
154-
*
155-
* ```prisma
156-
* user_id String @db.ObjectId
157-
* refresh_token String? @db.String
158-
* access_token String? @db.String
159-
* id_token String? @db.String
160-
* ```
161-
*
162-
* Everything else should be the same.
163-
*
164-
* ### Naming Conventions
165-
*
166-
* If mixed snake_case and camelCase column names is an issue for you and/or your underlying database system, we recommend using Prisma's `@map()`([see the documentation here](https://www.prisma.io/docs/concepts/components/prisma-schema/names-in-underlying-database)) feature to change the field names. This won't affect Auth.js, but will allow you to customize the column names to whichever naming convention you wish.
167-
*
168-
* For example, moving to `snake_case` and plural table names.
169-
*
170-
* ```json title="schema.prisma"
171-
* model Account {
172-
* id String @id @default(cuid())
173-
* userId String @map("user_id")
174-
* type String
175-
* provider String
176-
* providerAccountId String @map("provider_account_id")
177-
* refresh_token String? @db.Text
178-
* access_token String? @db.Text
179-
* expires_at Int?
180-
* token_type String?
181-
* scope String?
182-
* id_token String? @db.Text
183-
* session_state String?
184-
*
185-
* user User @relation(fields: [userId], references: [id], onDelete: Cascade)
186-
*
187-
* @@unique([provider, providerAccountId])
188-
* @@map("accounts")
189-
* }
190-
*
191-
* model Session {
192-
* id String @id @default(cuid())
193-
* sessionToken String @unique @map("session_token")
194-
* userId String @map("user_id")
195-
* expires DateTime
196-
* user User @relation(fields: [userId], references: [id], onDelete: Cascade)
197-
*
198-
* @@map("sessions")
199-
* }
200-
*
201-
* model User {
202-
* id String @id @default(cuid())
203-
* name String?
204-
* email String? @unique
205-
* emailVerified DateTime? @map("email_verified")
206-
* image String?
207-
* accounts Account[]
208-
* sessions Session[]
209-
* authenticators Authenticator[]
210-
*
211-
* @@map("users")
212-
* }
213-
*
214-
* model VerificationToken {
215-
* identifier String
216-
* token String @unique
217-
* expires DateTime
218-
*
219-
* @@unique([identifier, token])
220-
* @@map("verificationtokens")
221-
* }
222-
*
223-
* model Authenticator {
224-
* id String @id @default(cuid())
225-
* credentialID String @unique
226-
* userId String
227-
* providerAccountId String
228-
* credentialPublicKey String
229-
* counter Int
230-
* credentialDeviceType String
231-
* credentialBackedUp Boolean
232-
* transports String?
233-
*
234-
* user User @relation(fields: [userId], references: [id], onDelete: Cascade)
235-
* }
236-
* ```
237-
*
238-
**/
23927
export function PrismaAdapter(
24028
prisma: PrismaClient | ReturnType<PrismaClient["$extends"]>
24129
): Adapter {

0 commit comments

Comments
 (0)