1
0

city.sql.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 :one
  10. INSERT INTO city (
  11. name,
  12. slug
  13. ) VALUES (
  14. $1,
  15. $2
  16. ) RETURNING slug, name
  17. `
  18. type CreateCityParams struct {
  19. Name string `json:"name"`
  20. Slug string `json:"slug"`
  21. }
  22. // Create a new city. The slug must be unique.
  23. // This is the second line of the comment
  24. // This is the third line
  25. func (q *Queries) CreateCity(ctx context.Context, arg CreateCityParams) (City, error) {
  26. row := q.queryRow(ctx, q.createCityStmt, createCity, arg.Name, arg.Slug)
  27. var i City
  28. err := row.Scan(&i.Slug, &i.Name)
  29. return i, err
  30. }
  31. const getCity = `-- name: GetCity :one
  32. SELECT slug, name
  33. FROM city
  34. WHERE slug = $1
  35. `
  36. func (q *Queries) GetCity(ctx context.Context, slug string) (City, error) {
  37. row := q.queryRow(ctx, q.getCityStmt, getCity, slug)
  38. var i City
  39. err := row.Scan(&i.Slug, &i.Name)
  40. return i, err
  41. }
  42. const listCities = `-- name: ListCities :many
  43. SELECT slug, name
  44. FROM city
  45. ORDER BY name
  46. `
  47. func (q *Queries) ListCities(ctx context.Context) ([]City, error) {
  48. rows, err := q.query(ctx, q.listCitiesStmt, listCities)
  49. if err != nil {
  50. return nil, err
  51. }
  52. defer rows.Close()
  53. var items []City
  54. for rows.Next() {
  55. var i City
  56. if err := rows.Scan(&i.Slug, &i.Name); err != nil {
  57. return nil, err
  58. }
  59. items = append(items, i)
  60. }
  61. if err := rows.Close(); err != nil {
  62. return nil, err
  63. }
  64. if err := rows.Err(); err != nil {
  65. return nil, err
  66. }
  67. return items, nil
  68. }
  69. const updateCityName = `-- name: UpdateCityName :exec
  70. UPDATE city
  71. SET name = $2
  72. WHERE slug = $1
  73. `
  74. type UpdateCityNameParams struct {
  75. Slug string `json:"slug"`
  76. Name string `json:"name"`
  77. }
  78. func (q *Queries) UpdateCityName(ctx context.Context, arg UpdateCityNameParams) error {
  79. _, err := q.exec(ctx, q.updateCityNameStmt, updateCityName, arg.Slug, arg.Name)
  80. return err
  81. }