2023-09-20 15:26:52 +02:00
|
|
|
import prisma from '@typebot.io/lib/prisma'
|
2023-08-24 07:48:30 +02:00
|
|
|
import { Answer, Result } from '@typebot.io/schemas'
|
2023-07-18 14:31:20 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
id: string
|
|
|
|
}
|
|
|
|
export const findResult = ({ id }: Props) =>
|
|
|
|
prisma.result.findFirst({
|
2024-03-07 15:39:09 +01:00
|
|
|
where: { id, isArchived: { not: true } },
|
2023-07-18 14:31:20 +02:00
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
variables: true,
|
2023-08-24 07:48:30 +02:00
|
|
|
hasStarted: true,
|
|
|
|
answers: {
|
|
|
|
select: {
|
|
|
|
content: true,
|
|
|
|
blockId: true,
|
|
|
|
variableId: true,
|
|
|
|
},
|
|
|
|
},
|
2023-07-18 14:31:20 +02:00
|
|
|
},
|
2023-08-24 07:48:30 +02:00
|
|
|
}) as Promise<
|
|
|
|
| (Pick<Result, 'id' | 'variables' | 'hasStarted'> & {
|
|
|
|
answers: Pick<Answer, 'content' | 'blockId' | 'variableId'>[]
|
|
|
|
})
|
|
|
|
| null
|
|
|
|
>
|