从零搭建基于 AI 问答平台(7) 定义Quiz 数据模型

添加模型定义

修改 prisma/schema.prisma:

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
31
32
33
34
35
36
37
38
enum GameType {
mcq
open_ended
}

model Game {
id String @id @default(cuid())
userId String
questions Question[]
timeStarted DateTime
topic String
timeEnded DateTime?
gameType GameType

@@index([userId])
}

model topic_count {
id String @id @default(cuid())
topic String @unique
count Int
}

model Question {
id String @id @default(cuid())
question String
answer String
gameId String
options Json? // for mcq questions
percentageCorrect Float? // for open_ended questions
isCorrect Boolean? // for mcq questions
questionType GameType
userAnswer String?

game Game @relation(fields: [gameId], references: [id])

@@index([gameId])
}

执行:

1
bunx prisma db push
More...

请我喝杯咖啡吧~

支付宝
微信