Merge schemas into one file
This commit is contained in:
@ -13,30 +13,30 @@ const createBudget = `-- name: CreateBudget :one
|
||||
INSERT INTO budgets
|
||||
(name, last_modification)
|
||||
VALUES ($1, NOW())
|
||||
RETURNING name, last_modification, id
|
||||
RETURNING id, name, last_modification
|
||||
`
|
||||
|
||||
func (q *Queries) CreateBudget(ctx context.Context, name string) (Budget, error) {
|
||||
row := q.db.QueryRowContext(ctx, createBudget, name)
|
||||
var i Budget
|
||||
err := row.Scan(&i.Name, &i.LastModification, &i.ID)
|
||||
err := row.Scan(&i.ID, &i.Name, &i.LastModification)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getBudget = `-- name: GetBudget :one
|
||||
SELECT name, last_modification, id FROM budgets
|
||||
SELECT id, name, last_modification FROM budgets
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetBudget(ctx context.Context, id uuid.UUID) (Budget, error) {
|
||||
row := q.db.QueryRowContext(ctx, getBudget, id)
|
||||
var i Budget
|
||||
err := row.Scan(&i.Name, &i.LastModification, &i.ID)
|
||||
err := row.Scan(&i.ID, &i.Name, &i.LastModification)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getBudgetsForUser = `-- name: GetBudgetsForUser :many
|
||||
SELECT budgets.name, budgets.last_modification, budgets.id FROM budgets
|
||||
SELECT budgets.id, budgets.name, budgets.last_modification FROM budgets
|
||||
LEFT JOIN user_budgets ON budgets.id = user_budgets.budget_id
|
||||
WHERE user_budgets.user_id = $1
|
||||
`
|
||||
@ -50,7 +50,7 @@ func (q *Queries) GetBudgetsForUser(ctx context.Context, userID uuid.UUID) ([]Bu
|
||||
var items []Budget
|
||||
for rows.Next() {
|
||||
var i Budget
|
||||
if err := rows.Scan(&i.Name, &i.LastModification, &i.ID); err != nil {
|
||||
if err := rows.Scan(&i.ID, &i.Name, &i.LastModification); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
|
Reference in New Issue
Block a user