query-building.sql.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // source: query-building.sql
  3. package jets
  4. import (
  5. "context"
  6. )
  7. const countPilots = `-- name: CountPilots :one
  8. SELECT COUNT(*) FROM pilots
  9. `
  10. func (q *Queries) CountPilots(ctx context.Context) (int64, error) {
  11. row := q.db.QueryRowContext(ctx, countPilots)
  12. var count int64
  13. err := row.Scan(&count)
  14. return count, err
  15. }
  16. const deletePilot = `-- name: DeletePilot :exec
  17. DELETE FROM pilots WHERE id = $1
  18. `
  19. func (q *Queries) DeletePilot(ctx context.Context, id int32) error {
  20. _, err := q.db.ExecContext(ctx, deletePilot, id)
  21. return err
  22. }
  23. const listPilots = `-- name: ListPilots :many
  24. SELECT id, name FROM pilots LIMIT 5
  25. `
  26. func (q *Queries) ListPilots(ctx context.Context) ([]Pilot, error) {
  27. rows, err := q.db.QueryContext(ctx, listPilots)
  28. if err != nil {
  29. return nil, err
  30. }
  31. defer rows.Close()
  32. var items []Pilot
  33. for rows.Next() {
  34. var i Pilot
  35. if err := rows.Scan(&i.ID, &i.Name); err != nil {
  36. return nil, err
  37. }
  38. items = append(items, i)
  39. }
  40. if err := rows.Close(); err != nil {
  41. return nil, err
  42. }
  43. if err := rows.Err(); err != nil {
  44. return nil, err
  45. }
  46. return items, nil
  47. }