city.sql.go 1.8 KB

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