// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.28.0 // source: leagues.sql package dbgen import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const CheckLeagueSupport = `-- name: CheckLeagueSupport :one SELECT EXISTS( SELECT 1 FROM leagues WHERE id = $1 AND is_active = true ) ` func (q *Queries) CheckLeagueSupport(ctx context.Context, id int64) (bool, error) { row := q.db.QueryRow(ctx, CheckLeagueSupport, id) var exists bool err := row.Scan(&exists) return exists, err } const GetAllLeagues = `-- name: GetAllLeagues :many SELECT id, name, country_code, bet365_id, is_active, sport_id FROM leagues WHERE ( country_code = $1 OR $1 IS NULL ) AND ( sport_id = $2 OR $2 IS NULL ) AND ( is_active = $3 OR $3 IS NULL ) LIMIT $5 OFFSET $4 ` type GetAllLeaguesParams struct { CountryCode pgtype.Text `json:"country_code"` SportID pgtype.Int4 `json:"sport_id"` IsActive pgtype.Bool `json:"is_active"` Offset pgtype.Int4 `json:"offset"` Limit pgtype.Int4 `json:"limit"` } type GetAllLeaguesRow struct { ID int64 `json:"id"` Name string `json:"name"` CountryCode pgtype.Text `json:"country_code"` Bet365ID pgtype.Int4 `json:"bet365_id"` IsActive pgtype.Bool `json:"is_active"` SportID int32 `json:"sport_id"` } func (q *Queries) GetAllLeagues(ctx context.Context, arg GetAllLeaguesParams) ([]GetAllLeaguesRow, error) { rows, err := q.db.Query(ctx, GetAllLeagues, arg.CountryCode, arg.SportID, arg.IsActive, arg.Offset, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() var items []GetAllLeaguesRow for rows.Next() { var i GetAllLeaguesRow if err := rows.Scan( &i.ID, &i.Name, &i.CountryCode, &i.Bet365ID, &i.IsActive, &i.SportID, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const InsertLeague = `-- name: InsertLeague :exec INSERT INTO leagues ( id, name, country_code, bet365_id, sport_id, is_active ) VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name, country_code = EXCLUDED.country_code, bet365_id = EXCLUDED.bet365_id, is_active = EXCLUDED.is_active, sport_id = EXCLUDED.sport_id ` type InsertLeagueParams struct { ID int64 `json:"id"` Name string `json:"name"` CountryCode pgtype.Text `json:"country_code"` Bet365ID pgtype.Int4 `json:"bet365_id"` SportID int32 `json:"sport_id"` IsActive pgtype.Bool `json:"is_active"` } func (q *Queries) InsertLeague(ctx context.Context, arg InsertLeagueParams) error { _, err := q.db.Exec(ctx, InsertLeague, arg.ID, arg.Name, arg.CountryCode, arg.Bet365ID, arg.SportID, arg.IsActive, ) return err } const SetLeagueActive = `-- name: SetLeagueActive :exec UPDATE leagues SET is_active = $2 WHERE id = $1 ` type SetLeagueActiveParams struct { ID int64 `json:"id"` IsActive pgtype.Bool `json:"is_active"` } func (q *Queries) SetLeagueActive(ctx context.Context, arg SetLeagueActiveParams) error { _, err := q.db.Exec(ctx, SetLeagueActive, arg.ID, arg.IsActive) return err } const UpdateLeague = `-- name: UpdateLeague :exec UPDATE leagues SET name = COALESCE($2, name), country_code = COALESCE($3, country_code), bet365_id = COALESCE($4, bet365_id), is_active = COALESCE($5, is_active), sport_id = COALESCE($6, sport_id) WHERE id = $1 ` type UpdateLeagueParams struct { ID int64 `json:"id"` Name pgtype.Text `json:"name"` CountryCode pgtype.Text `json:"country_code"` Bet365ID pgtype.Int4 `json:"bet365_id"` IsActive pgtype.Bool `json:"is_active"` SportID pgtype.Int4 `json:"sport_id"` } func (q *Queries) UpdateLeague(ctx context.Context, arg UpdateLeagueParams) error { _, err := q.db.Exec(ctx, UpdateLeague, arg.ID, arg.Name, arg.CountryCode, arg.Bet365ID, arg.IsActive, arg.SportID, ) return err } const UpdateLeagueByBet365ID = `-- name: UpdateLeagueByBet365ID :exec UPDATE leagues SET name = COALESCE($2, name), id = COALESCE($3, id), country_code = COALESCE($4, country_code), is_active = COALESCE($5, is_active), sport_id = COALESCE($6, sport_id) WHERE bet365_id = $1 ` type UpdateLeagueByBet365IDParams struct { Bet365ID pgtype.Int4 `json:"bet365_id"` Name pgtype.Text `json:"name"` ID pgtype.Int8 `json:"id"` CountryCode pgtype.Text `json:"country_code"` IsActive pgtype.Bool `json:"is_active"` SportID pgtype.Int4 `json:"sport_id"` } func (q *Queries) UpdateLeagueByBet365ID(ctx context.Context, arg UpdateLeagueByBet365IDParams) error { _, err := q.db.Exec(ctx, UpdateLeagueByBet365ID, arg.Bet365ID, arg.Name, arg.ID, arg.CountryCode, arg.IsActive, arg.SportID, ) return err }