Add transaction detail view
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
-- name: GetTransaction :one
|
||||
SELECT * FROM transactions
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: CreateTransaction :one
|
||||
INSERT INTO transactions
|
||||
(date, memo, amount, account_id, payee_id, category_id)
|
||||
|
@ -63,6 +63,26 @@ func (q *Queries) DeleteAllTransactions(ctx context.Context, budgetID uuid.UUID)
|
||||
return result.RowsAffected()
|
||||
}
|
||||
|
||||
const getTransaction = `-- name: GetTransaction :one
|
||||
SELECT id, date, memo, amount, account_id, category_id, payee_id FROM transactions
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetTransaction(ctx context.Context, id uuid.UUID) (Transaction, error) {
|
||||
row := q.db.QueryRowContext(ctx, getTransaction, id)
|
||||
var i Transaction
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Date,
|
||||
&i.Memo,
|
||||
&i.Amount,
|
||||
&i.AccountID,
|
||||
&i.CategoryID,
|
||||
&i.PayeeID,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getTransactionsByMonthAndCategory = `-- name: GetTransactionsByMonthAndCategory :many
|
||||
SELECT date, category_id, budget_id, amount
|
||||
FROM transactions_by_month
|
||||
|
Reference in New Issue
Block a user