Given these schemas:
model awayinfo {
PlayerID Int @id
IsAway Boolean
playerinfo playerinfo @relation(fields: [PlayerID], references: [ID])
}
model playerinfo {
name String @db.VarChar(15)
ID Int @id @unique @default(autoincrement())
awayinfo awayinfo?
}
How would I create a prisma SQL update for the awayinfo table if the only identifier I have would be the Name of a player and not the ID?
what I tried:
I try to pass something into the WHERE part as seen below:
const result = await prisma.awayinfo.update({
where: {
PlayerID: {
name: name
}
},
data: {
IsAway: true,
}
});
but it always gives me the Error:
Invalid `prisma.awayinfo.update()` invocation:
Argument PlayerID: Got invalid value
{
name: 'Dummy'
}
on prisma.updateOneawayinfo. Provided Json, expected Int.
I got pretty desperate and even tried wonky selects like this one
const result = await prisma.awayinfo.update({
where: {
PlayerID: {
playerinfo: {
Where: {
name: name
},
select: {ID: true},
}}
}, .....
but obviously this would not work aswell. I wonder what I am missing here and I cannot find any example of a condition within the WHERE clause in the prisma documentation