Import category

This commit is contained in:
2021-12-06 20:19:38 +00:00
parent 674028d394
commit 495bc2b7c3
7 changed files with 274 additions and 32 deletions

View File

@ -0,0 +1,20 @@
-- name: CreateCategoryGroup :one
INSERT INTO category_groups
(name, budget_id)
VALUES ($1, $2)
RETURNING *;
-- name: GetCategoryGroups :many
SELECT category_groups.* FROM category_groups
WHERE category_groups.budget_id = $1;
-- name: CreateCategory :one
INSERT INTO categories
(name, category_group_id)
VALUES ($1, $2)
RETURNING *;
-- name: GetCategories :many
SELECT categories.*, category_groups.name as group FROM categories
INNER JOIN category_groups ON categories.category_group_id = category_groups.id
WHERE category_groups.budget_id = $1;

View File

@ -1,7 +1,7 @@
-- name: CreateTransaction :one
INSERT INTO transactions
(date, memo, amount, account_id, payee_id)
VALUES ($1, $2, $3, $4, $5)
(date, memo, amount, account_id, payee_id, category_id)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING *;
-- name: GetTransactionsForBudget :many