city.sql.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // versions:
  3. // sqlc v1.23.0
  4. // source: city.sql
  5. package ondeck
  6. import (
  7. "context"
  8. )
  9. const createCity = `-- name: CreateCity :exec
  10. INSERT INTO city (
  11. name,
  12. slug
  13. ) VALUES (
  14. ?,
  15. ?
  16. )
  17. `
  18. type CreateCityParams struct {
  19. Name string `json:"name"`
  20. Slug string `json:"slug"`
  21. }
  22. func (q *Queries) CreateCity(ctx context.Context, arg CreateCityParams) error {
  23. _, err := q.exec(ctx, q.createCityStmt, createCity, arg.Name, arg.Slug)
  24. return err
  25. }
  26. const getCity = `-- name: GetCity :one
  27. SELECT slug, name
  28. FROM city
  29. WHERE slug = ?
  30. `
  31. func (q *Queries) GetCity(ctx context.Context, slug string) (City, error) {
  32. row := q.queryRow(ctx, q.getCityStmt, getCity, slug)
  33. var i City
  34. err := row.Scan(&i.Slug, &i.Name)
  35. return i, err
  36. }
  37. const listCities = `-- name: ListCities :many
  38. SELECT slug, name
  39. FROM city
  40. ORDER BY name
  41. `
  42. func (q *Queries) ListCities(ctx context.Context) ([]City, error) {
  43. rows, err := q.query(ctx, q.listCitiesStmt, listCities)
  44. if err != nil {
  45. return nil, err
  46. }
  47. defer rows.Close()
  48. var items []City
  49. for rows.Next() {
  50. var i City
  51. if err := rows.Scan(&i.Slug, &i.Name); err != nil {
  52. return nil, err
  53. }
  54. items = append(items, i)
  55. }
  56. if err := rows.Close(); err != nil {
  57. return nil, err
  58. }
  59. if err := rows.Err(); err != nil {
  60. return nil, err
  61. }
  62. return items, nil
  63. }
  64. const updateCityName = `-- name: UpdateCityName :exec
  65. UPDATE city
  66. SET name = ?
  67. WHERE slug = ?
  68. `
  69. type UpdateCityNameParams struct {
  70. Name string `json:"name"`
  71. Slug string `json:"slug"`
  72. }
  73. func (q *Queries) UpdateCityName(ctx context.Context, arg UpdateCityNameParams) error {
  74. _, err := q.exec(ctx, q.updateCityNameStmt, updateCityName, arg.Name, arg.Slug)
  75. return err
  76. }