// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.13.0 // source: stats.sql package mysqlcore import ( "context" "database/sql" "git.aiterp.net/stufflog3/stufflog3-api/internal/sqltypes" ) const deleteStat = `-- name: DeleteStat :exec DELETE FROM stat WHERE id = ? AND scope_id = ? ` type DeleteStatParams struct { ID int ScopeID int } func (q *Queries) DeleteStat(ctx context.Context, arg DeleteStatParams) error { _, err := q.exec(ctx, q.deleteStatStmt, deleteStat, arg.ID, arg.ScopeID) return err } const getStat = `-- name: GetStat :one SELECT id, name, description, weight, allowed_amounts FROM stat WHERE scope_id = ? AND id = ? ` type GetStatParams struct { ScopeID int ID int } type GetStatRow struct { ID int Name string Description string Weight float64 AllowedAmounts sqltypes.NullRawMessage } func (q *Queries) GetStat(ctx context.Context, arg GetStatParams) (GetStatRow, error) { row := q.queryRow(ctx, q.getStatStmt, getStat, arg.ScopeID, arg.ID) var i GetStatRow err := row.Scan( &i.ID, &i.Name, &i.Description, &i.Weight, &i.AllowedAmounts, ) return i, err } const insertStat = `-- name: InsertStat :execresult INSERT INTO stat (scope_id, name, description, weight, allowed_amounts) VALUES (?, ?, ?, ?, ?) ` type InsertStatParams struct { ScopeID int Name string Description string Weight float64 AllowedAmounts sqltypes.NullRawMessage } func (q *Queries) InsertStat(ctx context.Context, arg InsertStatParams) (sql.Result, error) { return q.exec(ctx, q.insertStatStmt, insertStat, arg.ScopeID, arg.Name, arg.Description, arg.Weight, arg.AllowedAmounts, ) } const listStats = `-- name: ListStats :many SELECT id, name, description, weight, allowed_amounts FROM stat WHERE scope_id = ? ` type ListStatsRow struct { ID int Name string Description string Weight float64 AllowedAmounts sqltypes.NullRawMessage } func (q *Queries) ListStats(ctx context.Context, scopeID int) ([]ListStatsRow, error) { rows, err := q.query(ctx, q.listStatsStmt, listStats, scopeID) if err != nil { return nil, err } defer rows.Close() items := []ListStatsRow{} for rows.Next() { var i ListStatsRow if err := rows.Scan( &i.ID, &i.Name, &i.Description, &i.Weight, &i.AllowedAmounts, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const updateStat = `-- name: UpdateStat :exec UPDATE stat SET name = ?, description = ?, weight = ?, allowed_amounts = ? WHERE id = ? AND scope_id = ? ` type UpdateStatParams struct { Name string Description string Weight float64 AllowedAmounts sqltypes.NullRawMessage ID int ScopeID int } func (q *Queries) UpdateStat(ctx context.Context, arg UpdateStatParams) error { _, err := q.exec(ctx, q.updateStatStmt, updateStat, arg.Name, arg.Description, arg.Weight, arg.AllowedAmounts, arg.ID, arg.ScopeID, ) return err }