How to define this exact relation on prisma

Given this two models, how could I implement a relation between them, where a duel has 2 user Ids in it, one in the loser column, and one in the winner column, how should I define this? Prisma screams at me for putting 2 user relations on the same model.
model User {
id Int @id @default(autoincrement())
email String @unique
password String
name String @unique
crested_at DateTime @default(now())
duels Duel[]
TazooOnUser TazooOnUser[]

}

model Duel {
id Int @id @default(autoincrement())
winner User @relation(fields: [winnerId], references: [id])
loser User @relation(fields: [loserId], references: [id])
winnerId Int
loserId Int
crested_at DateTime @default(now())
}
model User {
id Int @id @default(autoincrement())
email String @unique
password String
name String @unique
crested_at DateTime @default(now())
duels Duel[]
TazooOnUser TazooOnUser[]

}

model Duel {
id Int @id @default(autoincrement())
winner User @relation(fields: [winnerId], references: [id])
loser User @relation(fields: [loserId], references: [id])
winnerId Int
loserId Int
crested_at DateTime @default(now())
}
If anyone could help me how to define this I would appreciate!
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server