Matias Vallone
04/06/2022, 2:52 PMinclude
field of a query and still retain the Typescript types?
eg:
export const findById = async (id: number, include: Prisma.ClaimInclude | undefined = undefined) => {
return dbClient.claim.findUnique({
where: {
id,
},
include,
})
}
and use it like this:
const claim = await findById(claimId , { assignedTo: true, })
currently I cannot access claim.assignedTo
Property 'assignedTo' does not exist on type 'Claim & {}'. Did you mean 'assignedToId'? ts(2551)thanks
This IsMe
04/06/2022, 3:03 PMMatias Vallone
04/06/2022, 3:06 PMThis IsMe
04/06/2022, 3:09 PMfindUnique({
where: { id: id },
include: { assignedTo: true },
})
Matias Vallone
04/06/2022, 3:11 PMMatias Vallone
04/06/2022, 4:56 PM