1
0

venue.sql.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // source: venue.sql
  3. package ondeck
  4. import (
  5. "context"
  6. "database/sql"
  7. )
  8. const createVenue = `-- name: CreateVenue :execresult
  9. INSERT INTO venue (
  10. slug,
  11. name,
  12. city,
  13. created_at,
  14. spotify_playlist,
  15. status,
  16. statuses,
  17. tags
  18. ) VALUES (
  19. ?,
  20. ?,
  21. ?,
  22. NOW(),
  23. ?,
  24. ?,
  25. ?,
  26. ?
  27. )
  28. `
  29. type CreateVenueParams struct {
  30. Slug string `json:"slug"`
  31. Name string `json:"name"`
  32. City string `json:"city"`
  33. SpotifyPlaylist string `json:"spotify_playlist"`
  34. Status VenuesStatus `json:"status"`
  35. Statuses sql.NullString `json:"statuses"`
  36. Tags sql.NullString `json:"tags"`
  37. }
  38. func (q *Queries) CreateVenue(ctx context.Context, arg CreateVenueParams) (sql.Result, error) {
  39. return q.exec(ctx, q.createVenueStmt, createVenue,
  40. arg.Slug,
  41. arg.Name,
  42. arg.City,
  43. arg.SpotifyPlaylist,
  44. arg.Status,
  45. arg.Statuses,
  46. arg.Tags,
  47. )
  48. }
  49. const deleteVenue = `-- name: DeleteVenue :exec
  50. DELETE FROM venue
  51. WHERE slug = ? AND slug = ?
  52. `
  53. type DeleteVenueParams struct {
  54. Slug string `json:"slug"`
  55. Slug_2 string `json:"slug_2"`
  56. }
  57. func (q *Queries) DeleteVenue(ctx context.Context, arg DeleteVenueParams) error {
  58. _, err := q.exec(ctx, q.deleteVenueStmt, deleteVenue, arg.Slug, arg.Slug_2)
  59. return err
  60. }
  61. const getVenue = `-- name: GetVenue :one
  62. SELECT id, status, statuses, slug, name, city, spotify_playlist, songkick_id, tags, created_at
  63. FROM venue
  64. WHERE slug = ? AND city = ?
  65. `
  66. type GetVenueParams struct {
  67. Slug string `json:"slug"`
  68. City string `json:"city"`
  69. }
  70. func (q *Queries) GetVenue(ctx context.Context, arg GetVenueParams) (Venue, error) {
  71. row := q.queryRow(ctx, q.getVenueStmt, getVenue, arg.Slug, arg.City)
  72. var i Venue
  73. err := row.Scan(
  74. &i.ID,
  75. &i.Status,
  76. &i.Statuses,
  77. &i.Slug,
  78. &i.Name,
  79. &i.City,
  80. &i.SpotifyPlaylist,
  81. &i.SongkickID,
  82. &i.Tags,
  83. &i.CreatedAt,
  84. )
  85. return i, err
  86. }
  87. const listVenues = `-- name: ListVenues :many
  88. SELECT id, status, statuses, slug, name, city, spotify_playlist, songkick_id, tags, created_at
  89. FROM venue
  90. WHERE city = ?
  91. ORDER BY name
  92. `
  93. func (q *Queries) ListVenues(ctx context.Context, city string) ([]Venue, error) {
  94. rows, err := q.query(ctx, q.listVenuesStmt, listVenues, city)
  95. if err != nil {
  96. return nil, err
  97. }
  98. defer rows.Close()
  99. var items []Venue
  100. for rows.Next() {
  101. var i Venue
  102. if err := rows.Scan(
  103. &i.ID,
  104. &i.Status,
  105. &i.Statuses,
  106. &i.Slug,
  107. &i.Name,
  108. &i.City,
  109. &i.SpotifyPlaylist,
  110. &i.SongkickID,
  111. &i.Tags,
  112. &i.CreatedAt,
  113. ); err != nil {
  114. return nil, err
  115. }
  116. items = append(items, i)
  117. }
  118. if err := rows.Close(); err != nil {
  119. return nil, err
  120. }
  121. if err := rows.Err(); err != nil {
  122. return nil, err
  123. }
  124. return items, nil
  125. }
  126. const updateVenueName = `-- name: UpdateVenueName :exec
  127. UPDATE venue
  128. SET name = ?
  129. WHERE slug = ?
  130. `
  131. type UpdateVenueNameParams struct {
  132. Name string `json:"name"`
  133. Slug string `json:"slug"`
  134. }
  135. func (q *Queries) UpdateVenueName(ctx context.Context, arg UpdateVenueNameParams) error {
  136. _, err := q.exec(ctx, q.updateVenueNameStmt, updateVenueName, arg.Name, arg.Slug)
  137. return err
  138. }
  139. const venueCountByCity = `-- name: VenueCountByCity :many
  140. SELECT
  141. city,
  142. count(*)
  143. FROM venue
  144. GROUP BY 1
  145. ORDER BY 1
  146. `
  147. type VenueCountByCityRow struct {
  148. City string `json:"city"`
  149. Count int64 `json:"count"`
  150. }
  151. func (q *Queries) VenueCountByCity(ctx context.Context) ([]VenueCountByCityRow, error) {
  152. rows, err := q.query(ctx, q.venueCountByCityStmt, venueCountByCity)
  153. if err != nil {
  154. return nil, err
  155. }
  156. defer rows.Close()
  157. var items []VenueCountByCityRow
  158. for rows.Next() {
  159. var i VenueCountByCityRow
  160. if err := rows.Scan(&i.City, &i.Count); err != nil {
  161. return nil, err
  162. }
  163. items = append(items, i)
  164. }
  165. if err := rows.Close(); err != nil {
  166. return nil, err
  167. }
  168. if err := rows.Err(); err != nil {
  169. return nil, err
  170. }
  171. return items, nil
  172. }