Halvor
07/07/2021, 11:34 AMRyan
07/07/2021, 11:48 AMHalvor
07/07/2021, 5:15 PMmodel match {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
session_id BigInt @unique
session_key String
arbitrated arbitrated?
}
model arbitrated {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
match match? @relation(fields: [matchId], references: [id])
matchId Int?
session_id BigInt @unique
}Halvor
07/07/2021, 5:18 PMHalvor
07/07/2021, 5:22 PMRyan
07/08/2021, 5:56 AMawait prisma.arbitrated.upsert({
where: {
session_id: matchId,
},
update: {},
create: {
match: { connect: { session_id: matchId } },
session_id: matchId,
},
})Halvor
07/08/2021, 8:59 AMHalvor
07/08/2021, 9:00 AMHalvor
07/08/2021, 9:03 AMconst arbitrated = await prisma.arbitrated.upsert({
where: {
session_id: matchId
},
update: {},
create: {
match: {
connect: {
session_id: matchId
}
}
}
});Halvor
07/08/2021, 9:04 AMHalvor
07/08/2021, 9:07 AMRyan
07/08/2021, 9:09 AMIn the where clause you’re proposing you are checking against the attribyte “session_id” of arbitrated right? What i want to do is to check against the 1-to-1 relation of the match table.This isn’t possible. You can only check on the fields of the model you’re performing an
upsert on.Ryan
07/08/2021, 9:09 AMHalvor
07/08/2021, 9:20 AMHalvor
07/08/2021, 9:20 AMHalvor
07/08/2021, 9:21 AMHalvor
07/08/2021, 9:25 AMRyan
07/08/2021, 9:30 AMsession_id in both tables? As it’s a 1-1 relation, you can easily check and return the entry using upsert.Halvor
07/08/2021, 9:37 AMHalvor
07/08/2021, 9:38 AMHalvor
07/08/2021, 9:38 AMHalvor
07/08/2021, 9:38 AMHalvor
07/08/2021, 9:39 AMarbitrated and match models."