sorarebuddy/model/fixture.sql.go

117 lines
2.6 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
// source: fixture.sql
package model
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
type CreateFixturesParams struct {
Slug string
DisplayName string
State string
StartDate pgtype.Timestamptz
EndDate pgtype.Timestamptz
GameWeek int32
}
const createOrUpdateFixture = `-- name: CreateOrUpdateFixture :exec
INSERT INTO fixtures (slug, display_name, state, start_date, end_date, game_week)
VALUES ($1, $2, $3, $4, $5, $6)
ON CONFLICT (slug) DO UPDATE
SET display_name = $2, state = $3, start_date = $4, end_date = $5, game_week = $6
`
type CreateOrUpdateFixtureParams struct {
Slug string
DisplayName string
State string
StartDate pgtype.Timestamptz
EndDate pgtype.Timestamptz
GameWeek int32
}
func (q *Queries) CreateOrUpdateFixture(ctx context.Context, arg CreateOrUpdateFixtureParams) error {
_, err := q.db.Exec(ctx, createOrUpdateFixture,
arg.Slug,
arg.DisplayName,
arg.State,
arg.StartDate,
arg.EndDate,
arg.GameWeek,
)
return err
}
const getAllFixtures = `-- name: GetAllFixtures :many
SELECT slug, display_name, state, start_date, end_date, game_week FROM fixtures
`
func (q *Queries) GetAllFixtures(ctx context.Context) ([]Fixture, error) {
rows, err := q.db.Query(ctx, getAllFixtures)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Fixture
for rows.Next() {
var i Fixture
if err := rows.Scan(
&i.Slug,
&i.DisplayName,
&i.State,
&i.StartDate,
&i.EndDate,
&i.GameWeek,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getFixtureByGameWeek = `-- name: GetFixtureByGameWeek :one
SELECT slug, display_name, state, start_date, end_date, game_week FROM fixtures WHERE game_week = $1
`
func (q *Queries) GetFixtureByGameWeek(ctx context.Context, gameWeek int32) (Fixture, error) {
row := q.db.QueryRow(ctx, getFixtureByGameWeek, gameWeek)
var i Fixture
err := row.Scan(
&i.Slug,
&i.DisplayName,
&i.State,
&i.StartDate,
&i.EndDate,
&i.GameWeek,
)
return i, err
}
const getFixtureBySlug = `-- name: GetFixtureBySlug :one
SELECT slug, display_name, state, start_date, end_date, game_week FROM fixtures WHERE slug = $1
`
func (q *Queries) GetFixtureBySlug(ctx context.Context, slug string) (Fixture, error) {
row := q.db.QueryRow(ctx, getFixtureBySlug, slug)
var i Fixture
err := row.Scan(
&i.Slug,
&i.DisplayName,
&i.State,
&i.StartDate,
&i.EndDate,
&i.GameWeek,
)
return i, err
}