sorarebuddy/db/client.go
2024-05-23 08:18:54 +04:00

42 lines
1.2 KiB
Go

package db
import (
"github.com/uptrace/bun"
"git.lehouerou.net/laurent/sorarebuddy/model"
)
type Client struct {
db *bun.DB
CardSupplies *CardSupplyRepository
Memberships *MembershipRepository
Countries *CountryRepository
Fixtures *FixtureRepository
Competitions *CompetitionRepository
Teams *TeamRepository
Games *GameRepository
Players *PlayerRepository
GamePlayers *GamePlayerRepository
GamePlayerScores *Repository[model.GamePlayerScore]
Zones *ZoneRepository
}
func NewClient(db *bun.DB) *Client {
return &Client{
db: db,
CardSupplies: NewCardSupplyRepository(db),
Memberships: NewMembershipRepository(db),
Countries: NewCountryRepository(db),
Fixtures: NewFixtureRepository(db),
Competitions: NewCompetitionRepository(db),
Teams: NewTeamRepository(db),
Games: NewGameRepository(db),
Players: NewPlayerRepository(db),
GamePlayers: NewGamePlayerRepository(db),
GamePlayerScores: NewRepository[model.GamePlayerScore](db, []string{"game_id", "player_slug"}),
Zones: NewZoneRepository(db),
}
}