const response = await prisma.teamMember.update({
where: {
teamId,
userId: memberToEditId,
},
data: {
role,
},
});
Argument where of type TeamMemberWhereUniqueInput needs exactly one argument, but you provided teamId and userId. Please choose one. Available args:
type TeamMemberWhereUniqueInput {
id?: String
}
Unknown arg `teamId` in where.teamId for type TeamMemberWhereUniqueInput. Did you mean `id`? Available args:
type TeamMemberWhereUniqueInput {
id?: String
}
Unknown arg `userId` in where.userId for type TeamMemberWhereUniqueInput. Did you mean `id`? Available args:
type TeamMemberWhereUniqueInput {
id?: String
}
Hey guys. I'm trying to update a specific document based off of a specific value(s) in my table, but it only seems to let me use the primary key for the table? My schema looks like:
model TeamMember {
id String @id @default(cuid())
teamId String
userId String
role Role @default(MEMBER)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Team {
id String @id @default(cuid())
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
TeamMember TeamMember[]
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
TeamMember TeamMember[]
theme Theme @default(LIGHT)
}
To fix this, temporarliy I can make a separate findFirst query, and use the returned row to get the ID of the row which i want to update. This is fine, however I know it can be done without doing this, and it is a little ugly having two queries when one can work just fine.
Any help would be greatly appreciated.
Prisma needs to uniquely identify a single record which needs to be updated, due to which the whereUnique
constraint is enforced.
For now, you can use updateMany
as a workaround for this, this unique constraint is not enforced for updateMany