PrismaP
Prisma13mo ago
8 replies
Seba

PrismaClientValidationError

Hello there, I'm currently stuck with this error:
Invalid  `prisma.ticket.create()` invocation in
./src/lib/server/ticket.ts:12:16
   9     phone_number: string,
  10     userId?: number
  11 ) =>
→ 12     prisma.ticket.create({
       data: {
         title: "Title",
         description: "Description",
         createdBy: {
           connect: undefined
         },
         info: {
           connectOrCreate: {
             where: {
               userId: undefined,
               name: "name",
               surname: "surname",
               email: "email",
               phone_number: "tel",
     ?         id?: Int,
     ?         name_surname_phone_number_email?: InformationNameSurnamePhone_numberEmailCompoundUniqueInput,
     ?         AND?: InformationWhereInput | InformationWhereInput[],
     ?         OR?: InformationWhereInput[],
     ?         NOT?: InformationWhereInput | InformationWhereInput[],
     ?         users?: UserNullableScalarRelationFilter | UserWhereInput | Null,
     ?         tickets?: TicketListRelationFilter
             },
             create: {
               name: "name",
               surname: "surname",
               email: "email",
               phone_number: "tel"
             }
           }
         }
       }
     })
Argument `where` of type InformationWhereUniqueInput needs at least one of `id`, `userId` or `name_surname_phone_number_email` arguments. Available options are marked with ?.
clientVersion: '6.2.1'
Node.js v22.11.0

./src/lib/server/ticket.ts:
export const createTicket = (title: string, description: string, name: string, surname: string, email: string, phone_number: string, userId?: number) => prisma.ticket.create({
  data: {
    title,
    description,
    createdBy: { connect: userId ? { id: userId } : undefined },
    info: { connectOrCreate: { where: { userId, name, surname, email, phone_number }, create: { name, surname, email, phone_number } } }
  }
});

Does anyone know how to solve this?
Was this page helpful?