sorarebuddy/model/competition.sql.go

107 lines
3.3 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
// source: competition.sql
package model
import (
"context"
)
const getAllCompetitions = `-- name: GetAllCompetitions :many
SELECT competitions.slug, competitions.display_name, competitions.country_slug, competitions.competition_format, competitions.competition_type, competitions.picture_url, competitions.logo_url, competitions.zone_id,
zones.id, zones.display_name,
countries.slug, countries.code, countries.display_name, countries.three_letter_code, countries.flag_flat_64_url, countries.flag_flat_32_url, countries.flag_round_64_url, countries.flag_round_32_url
FROM competitions
LEFT JOIN zones ON competitions.zone_id = zones.id
LEFT JOIN countries ON competitions.country_slug = countries.slug
`
type GetAllCompetitionsRow struct {
Competition Competition
Zone Zone
Country Country
}
func (q *Queries) GetAllCompetitions(ctx context.Context) ([]GetAllCompetitionsRow, error) {
rows, err := q.db.Query(ctx, getAllCompetitions)
if err != nil {
return nil, err
}
defer rows.Close()
var items []GetAllCompetitionsRow
for rows.Next() {
var i GetAllCompetitionsRow
if err := rows.Scan(
&i.Competition.Slug,
&i.Competition.DisplayName,
&i.Competition.CountrySlug,
&i.Competition.CompetitionFormat,
&i.Competition.CompetitionType,
&i.Competition.PictureUrl,
&i.Competition.LogoUrl,
&i.Competition.ZoneID,
&i.Zone.ID,
&i.Zone.DisplayName,
&i.Country.Slug,
&i.Country.Code,
&i.Country.DisplayName,
&i.Country.ThreeLetterCode,
&i.Country.FlagFlat64Url,
&i.Country.FlagFlat32Url,
&i.Country.FlagRound64Url,
&i.Country.FlagRound32Url,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getCompetitionBySlug = `-- name: GetCompetitionBySlug :one
SELECT competitions.slug, competitions.display_name, competitions.country_slug, competitions.competition_format, competitions.competition_type, competitions.picture_url, competitions.logo_url, competitions.zone_id,
zones.id, zones.display_name,
countries.slug, countries.code, countries.display_name, countries.three_letter_code, countries.flag_flat_64_url, countries.flag_flat_32_url, countries.flag_round_64_url, countries.flag_round_32_url
FROM competitions
LEFT JOIN zones ON competitions.zone_id = zones.id
LEFT JOIN countries ON competitions.country_slug = countries.slug
WHERE competitions.slug = $1
`
type GetCompetitionBySlugRow struct {
Competition Competition
Zone Zone
Country Country
}
func (q *Queries) GetCompetitionBySlug(ctx context.Context, slug string) (GetCompetitionBySlugRow, error) {
row := q.db.QueryRow(ctx, getCompetitionBySlug, slug)
var i GetCompetitionBySlugRow
err := row.Scan(
&i.Competition.Slug,
&i.Competition.DisplayName,
&i.Competition.CountrySlug,
&i.Competition.CompetitionFormat,
&i.Competition.CompetitionType,
&i.Competition.PictureUrl,
&i.Competition.LogoUrl,
&i.Competition.ZoneID,
&i.Zone.ID,
&i.Zone.DisplayName,
&i.Country.Slug,
&i.Country.Code,
&i.Country.DisplayName,
&i.Country.ThreeLetterCode,
&i.Country.FlagFlat64Url,
&i.Country.FlagFlat32Url,
&i.Country.FlagRound64Url,
&i.Country.FlagRound32Url,
)
return i, err
}