250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- evm
- solidity
- CSS
- express.js
- Redux
- blockchain
- 삶
- concept
- JavaScript
- graphQL
- web
- CLASS
- API
- useState
- hardhat
- built in object
- bitcoin
- HTML
- SSR
- Interface
- nextJS
- node.js
- 기준
- Props
- REACT
- middleware
- error
- typeScript
- tailwindcss
- Ethereum
Archives
- Today
- Total
ReasonJun
Prisma : Next Auth Google provider error 본문
728x90
When :
When implementing login using prisma and nextauth.
Error message :
[next-auth][error][adapter_error_getUserByAccount]
https://next-auth.js.org/errors#adapter_error_getuserbyaccount
Invalid `prisma.account.findUnique()` invocation:
prisma code :
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
// Add this
relationMode = "prisma"
}
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@index([userId], map: "Account_userId_fkey")
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId], map: "Session_userId_fkey")
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
active Boolean @default(false)
image String?
role String?
hashedPassword String?
userType UserType @default(User)
accounts Account[]
sessions Session[]
ActivateToken ActivateToken[]
}
model ActivateToken {
id String @id @default(cuid())
token String @unique
activatedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
userId String
@@index([userId])
}
enum UserType {
User
Admin
Youtuber
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
}
Solution : remove 'map: "~~~"'
Why ?
In the Prisma schema code you provided, the line @@index([userId], map: "Account_userId_fkey") is defining an index for the "Account" model. Let's break down what this line means:
- @@index: This is a Prisma schema decorator that is used to define an index on the database table associated with the "Account" model. Indexes are used to optimize database query performance by allowing faster lookup and retrieval of rows based on the indexed columns.
- ([userId], map: "Account_userId_fkey"): This part of the code specifies the index definition. It consists of two components:
- ([userId]): This is an array of column names on which the index is defined. In this case, the index is defined on the "userId" column of the "Account" model. This means that the database will create an index on the "userId" column, which will improve query performance for operations that involve searching or filtering by the "userId" column.
- map: "Account_userId_fkey": The map option provides a name for the index. In this case, the index is named "Account_userId_fkey." This name is typically used as a reference when working with the database, and it helps in uniquely identifying the index.
In summary, the @@index decorator in your Prisma schema is creating an index on the "userId" column of the "Account" model to improve query performance when searching or filtering records based on the "userId" value. The name of the index is specified as "Account_userId_fkey."
For this reason, 'findUnique' of the account could not be found.
728x90
Comments