PrismaP
Prisma2y ago
2 replies
ShaDoW

Need help with schema

I have models - Question and Answer
There is a one to many relation : 1 Question has many Answers
But I also need a relation for a single Answer, I will show the schema file, it is currently giving me error


model Question {
  id              Int      @id @default(autoincrement())
  title           String
  points          Int?
  quiz            Quiz     @relation(fields: [quizId], references: [id])
  quizId          Int
  answers         Answer[]
  correctAnswerId Int? 
  correctAnswer Answer? @relation(name: "correctAnswer", fields: [correctAnswerId], references: [id])
}

model Answer {
  id         Int      @id @default(autoincrement())
  title      String
  question   Question @relation(fields: [questionId], references: [id])
  questionId Int
}
Was this page helpful?