Sun「無用」
Sun「無用」
Explore posts from servers
PPrisma
Created by Sun「無用」 on 6/1/2024 in #help-and-questions
Cleaning code
So, just building a basic scoreboard side project, which I need teams and scores for it. Is there any ways to clean up these models? They just seem kinda clunky to me, dunno if I'm the problem here.
model Team {
id String @id @default(uuid()) @map("team_id")
slug String @unique @default(nanoid())
name String

LeftGame Game[] @relation("left_team")
RightGame Game[] @relation("right_team")

@@map("teams")
}

model Game {
id String @id @default(uuid()) @map("game_id")

leftTeamId String
leftTeam Team @relation("left_team", fields: [leftTeamId], references: [id])
leftScore Int @default(0)

rightTeamId String
rightTeam Team @relation("right_team", fields: [rightTeamId], references: [id])
rightScore Int @default(0)

@@map("games")
}
model Team {
id String @id @default(uuid()) @map("team_id")
slug String @unique @default(nanoid())
name String

LeftGame Game[] @relation("left_team")
RightGame Game[] @relation("right_team")

@@map("teams")
}

model Game {
id String @id @default(uuid()) @map("game_id")

leftTeamId String
leftTeam Team @relation("left_team", fields: [leftTeamId], references: [id])
leftScore Int @default(0)

rightTeamId String
rightTeam Team @relation("right_team", fields: [rightTeamId], references: [id])
rightScore Int @default(0)

@@map("games")
}
2 replies