Skip to content
Advertisement

Problem with prisma .upsert, Unkown argument

I have problem with prisma upsert(), I get info:

PrismaClientValidationError: Invalid prisma.prismaUser.upsert() invocation:

{ where: { email: ‘viola@prisma.io’ ~~~~~ }, update: { name: ‘Viola the Magnificent’ }, create: { email: ‘viola@prisma.io’, name: ‘Viola the Magnificent’, profileViews: 0, role: ‘admin’ } }

Unknown arg email in where.email for type prismaUserWhereUniqueInput. Did you mean id? Available args: type prismaUserWhereUniqueInput { id?

My code: schema.prisma

JavaScript

node.js

JavaScript

Anyone can help me and explain what is wrong?

Advertisement

Answer

The field in where clause of the upsert query should be unique.

In this case, the email field is not unique due to which you are getting this error.

Updating schema file by adding @unique attribute to the email field will solve the issue.

JavaScript
Advertisement