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?
7 Replies
Brendonovich
Brendonovich12mo ago
idk, this kinda looks like a problem with Prisma - the data you provided should match the VoteUncheckedCreateInput type, but the error you're getting is Prisma expecting a VoteCreateInput. Using connect and doing relation stuff would probs work but it's odd that it won't let u just put the foreign keys ok nevermind i guess UncheckedCreate doesn't allow setting foreign keys i swear that's how it used to be but ¯\_(ツ)_/¯ yeah nvm i'm thinking of VoteCreateManyInput - connect it is for you then
trash
trash12mo ago
thanks all. hmm no dice, ill report back. looks like post 2.1 you shouldnt have to write connect based on the docs nm i had to delete node modules ......
gxp91
gxp9112mo ago
@trash_dev does that userId exist in the User table?
trash
trash12mo ago
yeah.. the problem was fixed after i blew and recreated node_modules...smh all my original code was fine and didnt need connect
gxp91
gxp9112mo ago
weird i wonder if something broke when your last npm install ran. Since NPM Install calls prisma generate.
Brendonovich
Brendonovich12mo ago
lmaooo rip
Want results from more Discord servers?
Add your server
More Posts