feat: it works

This commit is contained in:
Anatoly Antonov 2025-03-26 17:14:00 +03:00
parent 6302dd62d6
commit 778d5ef146
25 changed files with 638 additions and 106 deletions

View file

@ -7,19 +7,29 @@ package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const getStationByID = `-- name: GetStationByID :one
select id, slug, status
from stations
where id = $1
const getSatellites = `-- name: GetSatellites :many
select id, display_name, status
from satellites
`
func (q *Queries) GetStationByID(ctx context.Context, id pgtype.UUID) (Station, error) {
row := q.db.QueryRow(ctx, getStationByID, id)
var i Station
err := row.Scan(&i.ID, &i.Slug, &i.Status)
return i, err
func (q *Queries) GetSatellites(ctx context.Context) ([]Satellite, error) {
rows, err := q.db.Query(ctx, getSatellites)
if err != nil {
return nil, err
}
defer rows.Close()
var items []Satellite
for rows.Next() {
var i Satellite
if err := rows.Scan(&i.ID, &i.DisplayName, &i.Status); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}