Andrade
Andrade
PPrisma
Created by Andrade on 6/5/2024 in #help-and-questions
Type '{ connectOrCreate: { where: { state_name: string; }; create: { state_name: string; }; }; }' is
model Repairs { id Int @id @default(autoincrement()) machine_id Int technician_id Int state_id Int created_by Int created_at DateTime @default(now()) state RepairStates @relation(fields: [state_id], references: [id]) machine Machines @relation(fields: [machine_id], references: [id]) createdBy Employees @relation("repairCreatedBy", fields: [created_by], references: [id]) technician Employees @relation("technician", fields: [technician_id], references: [id]) diagnose Diagnoses? repairObservation RepairObservations? delivery Deliveries? quote Quotes? inventory Inventory? admissionObservation AdmissionObservations? } model RepairStates { id Int @id @default(autoincrement()) state_name String @unique repairs Repairs[] } return this.prisma.machines.create({ data: { ...machineData, repairs: { create: { state: { connectOrCreate: { where: { state_name: 'EN_DIAGNOSTICO' }, create: { state_name: 'EN_DIAGNOSTICO' }, }, }, technician_id: repair.technician_id, created_by: repair.created_by, admissionObservation: { create: { ...admission_observations, components: { createMany: { data: componentsData }, }, }, }, }, }, }, }); Type '{ connectOrCreate: { where: { state_name: string; }; create: { state_name: string; }; }; }' is not assignable to type 'never'.ts(2322) (property) state: { connectOrCreate: { where: { state_name: string; }; create: { state_name: string; }; }; }
2 replies
PPrisma
Created by Andrade on 6/5/2024 in #help-and-questions
Argument is missing
When I try to create a repair it throws me this error Error: 15 const componentsData = components.map((component) => ({ 16 component_name: component, 17 })); → 18 return this.prisma.repairs.create({ data: { state_id: 2, created_by: 1, technician_id: 2, machine_id: undefined, + state: { + create: RepairStatesCreateWithoutRepairsInput | RepairStatesUncheckedCreateWithoutRepairsInput, + connectOrCreate: RepairStatesCreateOrConnectWithoutRepairsInput, + connect: RepairStatesWhereUniqueInput + } } }) Argument state is missing. Function: return this.prisma.repairs.create({ data: { state_id: 2, created_by: repairData.created_by, technician_id: repairData.technician_id, machine_id: repairData.machine_id,
}, }); Models model Repairs { id Int @id @default(autoincrement()) machine_id Int technician_id Int state_id Int created_by Int created_at DateTime @default(now()) state RepairStates @relation(fields: [state_id], references: [id]) machine Machines @relation(fields: [machine_id], references: [id]) createdBy Employees @relation("repairCreatedBy", fields: [created_by], references: [id]) technician Employees @relation("technician", fields: [technician_id], references: [id]) diagnose Diagnoses? repairObservation RepairObservations? delivery Deliveries? quote Quotes? inventory Inventory? admissionObservation AdmissionObservations? } model RepairStates { id Int @id @default(autoincrement()) state_name String repairs Repairs[] }
1 replies