Next.js Discord

Discord Forum

Prisma schema for Authjs

Unanswered
Hackberry nipple gall parasitoid posted this in #help-forum
Open in Discord
Hackberry nipple gall parasitoidOP
model Account {
  id    String @id @default(auto()) @map("_id") @db.ObjectId
  userId             String   @db.ObjectId
  type               String
  provider           String
  providerAccountId  String
  refresh_token      String?  @db.ObjectId
  access_token       String?  @db.ObjectId
  expires_at         Int?
  token_type         String?
  scope              String?
  id_token           String?  @db.ObjectId
  session_state      String?

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

enum UserRole{
  ADMIN
  USER
}


model User {
  id    String @id @default(auto()) @map("_id") @db.ObjectId
  name          String?
  email         String?   @unique
  emailVerified DateTime?
  password      String?
  image         String?
  role          UserRole @default(USER)
  accounts      Account[]
}

model VerificationToken{
  id    String @id @default(auto()) @map("_id") @db.ObjectId
  email         String 
  token         String
  expires       DateTime

  @@unique([email,token])
}

is my schema correct for mongo ?

2 Replies