trash
trash
Explore posts from servers
TTCTheo's Typesafe Cult
Created by trash on 6/10/2023 in #questions
how do i prisma
given this model
model Vote {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId String
challenge Challenge? @relation(fields: [challengeId], references: [id])
challengeId Int?
solution Solution? @relation(fields: [solutionId], references: [id])
solutionId Int?

@@index([userId])
@@index([challengeId])
@@index([solutionId])
}
model Vote {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId String
challenge Challenge? @relation(fields: [challengeId], references: [id])
challengeId Int?
solution Solution? @relation(fields: [solutionId], references: [id])
solutionId Int?

@@index([userId])
@@index([challengeId])
@@index([solutionId])
}
i am executing this create
await prisma.vote.create({
data: {
challengeId,
userId,
}
});
await prisma.vote.create({
data: {
challengeId,
userId,
}
});
which results in this error
Argument `user` is missing.
- error Error:
Invalid `prisma.vote.create()` invocation:

{
data: {
challengeId: 3,
userId: "bdc8a494-9d98-474d-bbe5-b069d934c49b",
+ user: {
+ create: UserCreateWithoutVoteInput | UserUncheckedCreateWithoutVoteInput,
+ connectOrCreate: UserCreateOrConnectWithoutVoteInput,
+ connect: UserWhereUniqueInput
+ }
}
}
Argument `user` is missing.
- error Error:
Invalid `prisma.vote.create()` invocation:

{
data: {
challengeId: 3,
userId: "bdc8a494-9d98-474d-bbe5-b069d934c49b",
+ user: {
+ create: UserCreateWithoutVoteInput | UserUncheckedCreateWithoutVoteInput,
+ connectOrCreate: UserCreateOrConnectWithoutVoteInput,
+ connect: UserWhereUniqueInput
+ }
}
}
the userId and challengeId are both valid seems like this should work?
16 replies