Roy
08/09/2020, 9:44 PMModel User {
id Int @id
name String
}
2. Model Game
Model Game {
id Int @id
player1 PlayerInGame
player2 PlayerInGame
}
3. Model PlayerInGame
Model PlayerInGame {
id Int @id
player User
game Game
}
It gives me this error:
Error validating model "Game": Ambiguous relation detected. The fields player2
and player1
in model Game
both refer to PlayerInGame
. Please provide different relation names for them by adding `@relation(<name>).
How can i make this work...?
Thanks in advanceRyan
08/10/2020, 7:02 AMmodel User {
id Int @id
name String
games Game[]
}
model Game {
id Int @id
name String
users User[]
}
Roy
08/10/2020, 7:05 AMRyan
08/10/2020, 7:09 AMmodel User {
id Int @id
name String
playedGames PlayerInGame[]
}
model Game {
id Int @id
name String
users PlayerInGame[]
}
model PlayerInGame {
game Game @relation(fields: [gameId], references: [id])
player User @relation(fields: [playerId], references: [id])
gameId Int
playerId Int
@@id([gameId, playerId])
}
Roy
08/10/2020, 7:11 AM