1
0

venue.sql.go 3.9 KB

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