Correct way to get data based on email

Hello experimenting with t3-stack, What would be the correct way to query from my submissions table by checking if an email exists within the table ?
getSubmissionData: publicProcedure
.input(z.object({ text: z.string() }))
.query(({ input }) =>{
return prisma?.submissions.findUnique({where: {
email : input.email
}})
})
getSubmissionData: publicProcedure
.input(z.object({ text: z.string() }))
.query(({ input }) =>{
return prisma?.submissions.findUnique({where: {
email : input.email
}})
})
I do not have any submissions at the moment and am expecting it to return null or undefined. but I am instead getting
Property 'email' does not exist on type '{ text: string; }'.
Property 'email' does not exist on type '{ text: string; }'.
how can this be if I am expecting to pass in a string (users email)? Any clarification would be helpful thank you!
3 Replies
jakeAnon
jakeAnonOP2y ago
adding @unique to the email field seems to have fixed it
Neto
Neto2y ago
if the column need to be unique, you need to add @id to specify the table unique identifier or use @unique to let prisma know the column will have the unique contraint with unique columns, you can use findUnique
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server