♻️ Export bot-engine code into its own package
This commit is contained in:
27
packages/bot-engine/queries/findResult.ts
Normal file
27
packages/bot-engine/queries/findResult.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import prisma from '@typebot.io/lib/prisma'
|
||||
import { Answer, Result } from '@typebot.io/schemas'
|
||||
|
||||
type Props = {
|
||||
id: string
|
||||
}
|
||||
export const findResult = ({ id }: Props) =>
|
||||
prisma.result.findFirst({
|
||||
where: { id },
|
||||
select: {
|
||||
id: true,
|
||||
variables: true,
|
||||
hasStarted: true,
|
||||
answers: {
|
||||
select: {
|
||||
content: true,
|
||||
blockId: true,
|
||||
variableId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}) as Promise<
|
||||
| (Pick<Result, 'id' | 'variables' | 'hasStarted'> & {
|
||||
answers: Pick<Answer, 'content' | 'blockId' | 'variableId'>[]
|
||||
})
|
||||
| null
|
||||
>
|
||||
Reference in New Issue
Block a user