P
Prisma•8mo ago
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
}
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
}
1 Reply
RaphaelEtim
RaphaelEtim•8mo ago
Hi @ShaDoW 👋 Can you please share the error you are getting?
Want results from more Discord servers?
Add your server