Dimitri Ivashchuk
07/07/2021, 7:55 AMEvaluations: {
upsert: [
{
where: {
topic_id_assessment_record_id_unique: {
topicId: topicId as string,
assessmentRecordId: recordId as string,
},
},
create: {
User: {
connect: {
id: user.id,
},
},
Topic: {
connect: {
id: topicId as string,
},
},
Level: {
connect: {
id: levelId as string,
},
},
Stage: {
connect: {
id: stageId as string,
},
},
comment: comment as string,
score: 321,
},
update: {
levelId: levelId as string,
stageId: stageId as string,
},
model Evaluation {
id String @id @default(cuid())
assessmentRecordId String
userId String
topicId String
levelId String?
stageId String?
score Float
comment String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt @map(name: "updated_at")
Record AssessmentRecord @relation(fields: [assessmentRecordId], references: [id])
User User @relation(fields: [userId], references: [id])
Topic Topic @relation(fields: [topicId], references: [id])
Level Level? @relation(fields: [levelId], references: [id])
Stage Stage? @relation(fields: [stageId], references: [id])
@@unique([topicId, assessmentRecordId], name: "topic_id_assessment_record_id_unique")
@@map(name: "evaluations")
}
Both null and undefined as arguments throw error 😕Dimitri Ivashchuk
07/07/2021, 7:57 AMDimitri Ivashchuk
07/07/2021, 8:01 AMInvalid `prisma.assessmentRecord.update()` invocation:
{
where: {
id: 'ckqt3vtqa0327m1yb95ncr72i'
},
data: {
Evaluations: {
upsert: {
'0': {
where: {
topic_id_assessment_record_id_unique: {
topicId: 'ckqt3p1d90394njyb3j8fbu8g',
assessmentRecordId: 'ckqt3vtqa0327m1yb95ncr72i'
}
},
create: {
User: {
connect: {
id: 'ckqt3uchl0008m1yb16ytyiwa'
}
},
Topic: {
connect: {
id: 'ckqt3p1d90394njyb3j8fbu8g'
}
},
Level: {
connect: {
? id?: String
},
? create?: LevelCreateWithoutEvaluationsInput | LevelUncheckedCreateWithoutEvaluationsInput,
? connectOrCreate?: {
? where: LevelWhereUniqueInput,
? create: LevelCreateWithoutEvaluationsInput | LevelUncheckedCreateWithoutEvaluationsInput
? }
},
Stage: {
connect: {
? id?: String
},
? create?: StageCreateWithoutEvaluationsInput | StageUncheckedCreateWithoutEvaluationsInput,
? connectOrCreate?: {
? where: StageWhereUniqueInput,
? create: StageCreateWithoutEvaluationsInput | StageUncheckedCreateWithoutEvaluationsInput
? }
},
comment: undefined,
score: 321
},
update: {
levelId: undefined,
stageId: undefined
}
}
}
}
},
include: {
Evaluations: true
}
}
Argument data.Evaluations.upsert.0.create.Level.connect of type LevelWhereUniqueInput needs at least one argument. Available args are listed in green.
Argument data.Evaluations.upsert.0.create.Stage.connect of type StageWhereUniqueInput needs at least one argument. Available args are listed in green.Ryan
07/07/2021, 10:52 AMundefined or null then you need to omit the relation entirely. So a condition before the relation would be the way to go. Something like:
...(user.id && {
User: { connect: { id: user.id } }
})Dimitri Ivashchuk
07/12/2021, 6:45 AM