PrismaClientValidationError
Hello there, I'm currently stuck with this error:
./src/lib/server/ticket.ts:
Does anyone know how to solve this?
7 Replies
You selected to wait for the human sages. They'll share their wisdom soon.
Grab some tea while you wait, or check out
#ask-ai
if you'd like a quick chat with the bot anyway!This is my schema:
Hi @Seba
Can you try this query?
Notice how I'm using the compound unique constraint
@@unique([name, surname, phone_number, email])
in the where clause of connectOrCreate
.Thank you so much, it worked just fine, I wasn't aware of this syntax (
name_surname_phone_number_email
).
Just one last thing: is there a way to connect the info
with name_surname_phone_number_email
or the userId
?You can learn about that syntax in the documentation on working with compound unique constraints.
is there a way to connect the info with name_surname_phone_number_email or the userId?Yes, this is possible If
userId
is provided, it uses it as the unique identifier in the where clause. If userId
is not provided, it uses the compound unique constraint name_surname_phone_number_email
.I thought that, maybe, there was a more clever way to do that (i.e. with
OR
clause). Thanks anyway and thank you again for the resource.You're welcome