2
0
Files
bot/packages/models/features/answer.ts

37 lines
867 B
TypeScript
Raw Normal View History

import { z } from 'zod'
2022-11-29 10:02:40 +01:00
import { Answer as AnswerPrisma, Prisma } from 'db'
2021-12-30 10:24:16 +01:00
export const answerSchema = z.object({
createdAt: z.date(),
resultId: z.string(),
blockId: z.string(),
groupId: z.string(),
variableId: z.string().nullable(),
content: z.string(),
storageUsed: z.number().nullable(),
}) satisfies z.ZodType<AnswerPrisma>
2022-11-29 10:02:40 +01:00
export const answerInputSchema = answerSchema
.omit({
createdAt: true,
resultId: true,
variableId: true,
storageUsed: true,
})
.and(
z.object({
variableId: z.string().nullish(),
storageUsed: z.number().nullish(),
})
) satisfies z.ZodType<Prisma.AnswerUncheckedUpdateInput>
2022-11-21 11:12:43 +01:00
2022-01-03 17:39:59 +01:00
export type Stats = {
totalViews: number
totalStarts: number
totalCompleted: number
2022-01-03 17:39:59 +01:00
}
export type Answer = z.infer<typeof answerSchema>
2022-11-21 11:12:43 +01:00
export type AnswerInput = z.infer<typeof answerInputSchema>