81 lines
2.0 KiB
Go
81 lines
2.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.25.0
|
|
// source: country.sql
|
|
|
|
package model
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createOrUpdateCountry = `-- name: CreateOrUpdateCountry :exec
|
|
INSERT INTO countries (
|
|
slug,
|
|
code,
|
|
display_name,
|
|
three_letter_code,
|
|
flag_flat_64_url,
|
|
flag_flat_32_url,
|
|
flag_round_64_url,
|
|
flag_round_32_url
|
|
)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT (slug)
|
|
DO
|
|
UPDATE
|
|
SET code = EXCLUDED.code,
|
|
display_name = EXCLUDED.display_name,
|
|
three_letter_code = EXCLUDED.three_letter_code,
|
|
flag_flat_64_url = EXCLUDED.flag_flat_64_url,
|
|
flag_flat_32_url = EXCLUDED.flag_flat_32_url,
|
|
flag_round_64_url = EXCLUDED.flag_round_64_url,
|
|
flag_round_32_url = EXCLUDED.flag_round_32_url
|
|
`
|
|
|
|
type CreateOrUpdateCountryParams struct {
|
|
Slug string
|
|
Code string
|
|
DisplayName string
|
|
ThreeLetterCode string
|
|
FlagFlat64Url string
|
|
FlagFlat32Url string
|
|
FlagRound64Url string
|
|
FlagRound32Url string
|
|
}
|
|
|
|
func (q *Queries) CreateOrUpdateCountry(ctx context.Context, arg CreateOrUpdateCountryParams) error {
|
|
_, err := q.db.Exec(ctx, createOrUpdateCountry,
|
|
arg.Slug,
|
|
arg.Code,
|
|
arg.DisplayName,
|
|
arg.ThreeLetterCode,
|
|
arg.FlagFlat64Url,
|
|
arg.FlagFlat32Url,
|
|
arg.FlagRound64Url,
|
|
arg.FlagRound32Url,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const getCountryBySlug = `-- name: GetCountryBySlug :one
|
|
SELECT slug, code, display_name, three_letter_code, flag_flat_64_url, flag_flat_32_url, flag_round_64_url, flag_round_32_url
|
|
FROM countries
|
|
WHERE slug = $1
|
|
`
|
|
|
|
func (q *Queries) GetCountryBySlug(ctx context.Context, slug string) (Country, error) {
|
|
row := q.db.QueryRow(ctx, getCountryBySlug, slug)
|
|
var i Country
|
|
err := row.Scan(
|
|
&i.Slug,
|
|
&i.Code,
|
|
&i.DisplayName,
|
|
&i.ThreeLetterCode,
|
|
&i.FlagFlat64Url,
|
|
&i.FlagFlat32Url,
|
|
&i.FlagRound64Url,
|
|
&i.FlagRound32Url,
|
|
)
|
|
return i, err
|
|
}
|