Add ability to change is_open from API

This commit is contained in:
2022-03-02 21:15:56 +00:00
parent 4fb3c2a335
commit f26ee8f472
3 changed files with 15 additions and 5 deletions

View File

@ -196,19 +196,26 @@ func (q *Queries) SearchAccounts(ctx context.Context, arg SearchAccountsParams)
const updateAccount = `-- name: UpdateAccount :one
UPDATE accounts
SET name = $1,
on_budget = $2
WHERE accounts.id = $3
on_budget = $2,
is_open = $3
WHERE accounts.id = $4
RETURNING id, budget_id, name, on_budget, is_open
`
type UpdateAccountParams struct {
Name string
OnBudget bool
IsOpen bool
ID uuid.UUID
}
func (q *Queries) UpdateAccount(ctx context.Context, arg UpdateAccountParams) (Account, error) {
row := q.db.QueryRowContext(ctx, updateAccount, arg.Name, arg.OnBudget, arg.ID)
row := q.db.QueryRowContext(ctx, updateAccount,
arg.Name,
arg.OnBudget,
arg.IsOpen,
arg.ID,
)
var i Account
err := row.Scan(
&i.ID,

View File

@ -35,6 +35,7 @@ ORDER BY accounts.name;
-- name: UpdateAccount :one
UPDATE accounts
SET name = $1,
on_budget = $2
WHERE accounts.id = $3
on_budget = $2,
is_open = $3
WHERE accounts.id = $4
RETURNING *;