Loggest thy stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
3.1 KiB

3 years ago
3 years ago
3 years ago
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // versions:
  3. // sqlc v1.13.0
  4. // source: stats.sql
  5. package mysqlcore
  6. import (
  7. "context"
  8. "database/sql"
  9. "git.aiterp.net/stufflog3/stufflog3-api/internal/sqltypes"
  10. )
  11. const deleteStat = `-- name: DeleteStat :exec
  12. DELETE FROM stat WHERE id = ? AND scope_id = ?
  13. `
  14. type DeleteStatParams struct {
  15. ID int
  16. ScopeID int
  17. }
  18. func (q *Queries) DeleteStat(ctx context.Context, arg DeleteStatParams) error {
  19. _, err := q.exec(ctx, q.deleteStatStmt, deleteStat, arg.ID, arg.ScopeID)
  20. return err
  21. }
  22. const getStat = `-- name: GetStat :one
  23. SELECT id, name, description, weight, allowed_amounts FROM stat
  24. WHERE scope_id = ? AND id = ?
  25. `
  26. type GetStatParams struct {
  27. ScopeID int
  28. ID int
  29. }
  30. type GetStatRow struct {
  31. ID int
  32. Name string
  33. Description string
  34. Weight float64
  35. AllowedAmounts sqltypes.NullRawMessage
  36. }
  37. func (q *Queries) GetStat(ctx context.Context, arg GetStatParams) (GetStatRow, error) {
  38. row := q.queryRow(ctx, q.getStatStmt, getStat, arg.ScopeID, arg.ID)
  39. var i GetStatRow
  40. err := row.Scan(
  41. &i.ID,
  42. &i.Name,
  43. &i.Description,
  44. &i.Weight,
  45. &i.AllowedAmounts,
  46. )
  47. return i, err
  48. }
  49. const insertStat = `-- name: InsertStat :execresult
  50. INSERT INTO stat (scope_id, name, description, weight, allowed_amounts)
  51. VALUES (?, ?, ?, ?, ?)
  52. `
  53. type InsertStatParams struct {
  54. ScopeID int
  55. Name string
  56. Description string
  57. Weight float64
  58. AllowedAmounts sqltypes.NullRawMessage
  59. }
  60. func (q *Queries) InsertStat(ctx context.Context, arg InsertStatParams) (sql.Result, error) {
  61. return q.exec(ctx, q.insertStatStmt, insertStat,
  62. arg.ScopeID,
  63. arg.Name,
  64. arg.Description,
  65. arg.Weight,
  66. arg.AllowedAmounts,
  67. )
  68. }
  69. const listStats = `-- name: ListStats :many
  70. SELECT id, name, description, weight, allowed_amounts FROM stat
  71. WHERE scope_id = ?
  72. `
  73. type ListStatsRow struct {
  74. ID int
  75. Name string
  76. Description string
  77. Weight float64
  78. AllowedAmounts sqltypes.NullRawMessage
  79. }
  80. func (q *Queries) ListStats(ctx context.Context, scopeID int) ([]ListStatsRow, error) {
  81. rows, err := q.query(ctx, q.listStatsStmt, listStats, scopeID)
  82. if err != nil {
  83. return nil, err
  84. }
  85. defer rows.Close()
  86. items := []ListStatsRow{}
  87. for rows.Next() {
  88. var i ListStatsRow
  89. if err := rows.Scan(
  90. &i.ID,
  91. &i.Name,
  92. &i.Description,
  93. &i.Weight,
  94. &i.AllowedAmounts,
  95. ); err != nil {
  96. return nil, err
  97. }
  98. items = append(items, i)
  99. }
  100. if err := rows.Close(); err != nil {
  101. return nil, err
  102. }
  103. if err := rows.Err(); err != nil {
  104. return nil, err
  105. }
  106. return items, nil
  107. }
  108. const updateStat = `-- name: UpdateStat :exec
  109. UPDATE stat SET
  110. name = ?,
  111. description = ?,
  112. weight = ?,
  113. allowed_amounts = ?
  114. WHERE id = ? AND scope_id = ?
  115. `
  116. type UpdateStatParams struct {
  117. Name string
  118. Description string
  119. Weight float64
  120. AllowedAmounts sqltypes.NullRawMessage
  121. ID int
  122. ScopeID int
  123. }
  124. func (q *Queries) UpdateStat(ctx context.Context, arg UpdateStatParams) error {
  125. _, err := q.exec(ctx, q.updateStatStmt, updateStat,
  126. arg.Name,
  127. arg.Description,
  128. arg.Weight,
  129. arg.AllowedAmounts,
  130. arg.ID,
  131. arg.ScopeID,
  132. )
  133. return err
  134. }