diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2024-10-17 17:40:49 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2024-10-17 17:40:49 +0200 |
commit | 650053446d18424500ae6330b5ad0da81fa86373 (patch) | |
tree | 248fc9099a3acb7308621af6fba90dea1d99b852 /model/rexps.sql.go | |
parent | e6e3f258c519fdef01d1654a50b15335b57c4153 (diff) | |
download | gosten-650053446d18424500ae6330b5ad0da81fa86373.tar.gz gosten-650053446d18424500ae6330b5ad0da81fa86373.tar.bz2 gosten-650053446d18424500ae6330b5ad0da81fa86373.zip |
SQL: Fetch * instead of specific columns for simplicity
Diffstat (limited to 'model/rexps.sql.go')
-rw-r--r-- | model/rexps.sql.go | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/model/rexps.sql.go b/model/rexps.sql.go index 9b32c5b..9c3f1c0 100644 --- a/model/rexps.sql.go +++ b/model/rexps.sql.go @@ -7,39 +7,28 @@ package model import ( "context" - - "github.com/jackc/pgx/v5/pgtype" ) const getRecurExpenses = `-- name: GetRecurExpenses :many -SELECT id, description, expense, duration, start, "end" +SELECT id, description, expense, duration, start, "end", prev_id, category_id, user_id FROM recur_expenses WHERE user_id = $1 ` -type GetRecurExpensesRow struct { - ID int32 - Description pgtype.Text - Expense pgtype.Numeric - Duration pgtype.Interval - Start pgtype.Date - End pgtype.Date -} - // GetRecurExpenses // -// SELECT id, description, expense, duration, start, "end" +// SELECT id, description, expense, duration, start, "end", prev_id, category_id, user_id // FROM recur_expenses // WHERE user_id = $1 -func (q *Queries) GetRecurExpenses(ctx context.Context, userID int32) ([]GetRecurExpensesRow, error) { +func (q *Queries) GetRecurExpenses(ctx context.Context, userID int32) ([]RecurExpense, error) { rows, err := q.db.Query(ctx, getRecurExpenses, userID) if err != nil { return nil, err } defer rows.Close() - var items []GetRecurExpensesRow + var items []RecurExpense for rows.Next() { - var i GetRecurExpensesRow + var i RecurExpense if err := rows.Scan( &i.ID, &i.Description, @@ -47,6 +36,9 @@ func (q *Queries) GetRecurExpenses(ctx context.Context, userID int32) ([]GetRecu &i.Duration, &i.Start, &i.End, + &i.PrevID, + &i.CategoryID, + &i.UserID, ); err != nil { return nil, err } |