summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--model/categories.sql.go22
-rw-r--r--model/rexps.sql.go24
-rw-r--r--model/sexps.sql.go27
-rw-r--r--pages/pages.templ4
-rw-r--r--pages/pages_templ.go4
-rw-r--r--sql/categories.sql2
-rw-r--r--sql/rexps.sql2
-rw-r--r--sql/sexps.sql2
8 files changed, 40 insertions, 47 deletions
diff --git a/model/categories.sql.go b/model/categories.sql.go
index 7df0cb3..c67e20d 100644
--- a/model/categories.sql.go
+++ b/model/categories.sql.go
@@ -10,33 +10,33 @@ import (
)
const getCategoriesOrdered = `-- name: GetCategoriesOrdered :many
-SELECT id, name
+SELECT id, name, parent_id, user_id
FROM categories
WHERE user_id = $1
ORDER BY name ASC
`
-type GetCategoriesOrderedRow struct {
- ID int32
- Name string
-}
-
// GetCategoriesOrdered
//
-// SELECT id, name
+// SELECT id, name, parent_id, user_id
// FROM categories
// WHERE user_id = $1
// ORDER BY name ASC
-func (q *Queries) GetCategoriesOrdered(ctx context.Context, userID int32) ([]GetCategoriesOrderedRow, error) {
+func (q *Queries) GetCategoriesOrdered(ctx context.Context, userID int32) ([]Category, error) {
rows, err := q.db.Query(ctx, getCategoriesOrdered, userID)
if err != nil {
return nil, err
}
defer rows.Close()
- var items []GetCategoriesOrderedRow
+ var items []Category
for rows.Next() {
- var i GetCategoriesOrderedRow
- if err := rows.Scan(&i.ID, &i.Name); err != nil {
+ var i Category
+ if err := rows.Scan(
+ &i.ID,
+ &i.Name,
+ &i.ParentID,
+ &i.UserID,
+ ); err != nil {
return nil, err
}
items = append(items, i)
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
}
diff --git a/model/sexps.sql.go b/model/sexps.sql.go
index 8a54443..33b9f57 100644
--- a/model/sexps.sql.go
+++ b/model/sexps.sql.go
@@ -7,36 +7,37 @@ package model
import (
"context"
-
- "github.com/jackc/pgx/v5/pgtype"
)
const getSingleExpenses = `-- name: GetSingleExpenses :many
-SELECT id, description
+SELECT id, description, expense, date, corr_month, category_id, user_id
FROM single_expenses
WHERE user_id = $1
`
-type GetSingleExpensesRow struct {
- ID int64
- Description pgtype.Text
-}
-
// GetSingleExpenses
//
-// SELECT id, description
+// SELECT id, description, expense, date, corr_month, category_id, user_id
// FROM single_expenses
// WHERE user_id = $1
-func (q *Queries) GetSingleExpenses(ctx context.Context, userID int32) ([]GetSingleExpensesRow, error) {
+func (q *Queries) GetSingleExpenses(ctx context.Context, userID int32) ([]SingleExpense, error) {
rows, err := q.db.Query(ctx, getSingleExpenses, userID)
if err != nil {
return nil, err
}
defer rows.Close()
- var items []GetSingleExpensesRow
+ var items []SingleExpense
for rows.Next() {
- var i GetSingleExpensesRow
- if err := rows.Scan(&i.ID, &i.Description); err != nil {
+ var i SingleExpense
+ if err := rows.Scan(
+ &i.ID,
+ &i.Description,
+ &i.Expense,
+ &i.Date,
+ &i.CorrMonth,
+ &i.CategoryID,
+ &i.UserID,
+ ); err != nil {
return nil, err
}
items = append(items, i)
diff --git a/pages/pages.templ b/pages/pages.templ
index b9b7489..d2bfad2 100644
--- a/pages/pages.templ
+++ b/pages/pages.templ
@@ -21,7 +21,7 @@ templ index(user string) {
}
}
-templ recur(rows []model.GetRecurExpensesRow) {
+templ recur(rows []model.RecurExpense) {
@content() {
<ul class="list-group">
for _, r := range rows {
@@ -33,7 +33,7 @@ templ recur(rows []model.GetRecurExpensesRow) {
}
}
-templ categories(rows []model.GetCategoriesOrderedRow) {
+templ categories(rows []model.Category) {
@content() {
<ul class="list-group">
for _, r := range rows {
diff --git a/pages/pages_templ.go b/pages/pages_templ.go
index 263d903..fe1ad49 100644
--- a/pages/pages_templ.go
+++ b/pages/pages_templ.go
@@ -126,7 +126,7 @@ func index(user string) templ.Component {
})
}
-func recur(rows []model.GetRecurExpensesRow) templ.Component {
+func recur(rows []model.RecurExpense) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
@@ -196,7 +196,7 @@ func recur(rows []model.GetRecurExpensesRow) templ.Component {
})
}
-func categories(rows []model.GetCategoriesOrderedRow) templ.Component {
+func categories(rows []model.Category) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
diff --git a/sql/categories.sql b/sql/categories.sql
index e7d9579..2694adc 100644
--- a/sql/categories.sql
+++ b/sql/categories.sql
@@ -1,5 +1,5 @@
-- name: GetCategoriesOrdered :many
-SELECT id, name
+SELECT *
FROM categories
WHERE user_id = $1
ORDER BY name ASC; \ No newline at end of file
diff --git a/sql/rexps.sql b/sql/rexps.sql
index 87dc23f..e76c809 100644
--- a/sql/rexps.sql
+++ b/sql/rexps.sql
@@ -1,4 +1,4 @@
-- name: GetRecurExpenses :many
-SELECT id, description, expense, duration, start, "end"
+SELECT *
FROM recur_expenses
WHERE user_id = $1; \ No newline at end of file
diff --git a/sql/sexps.sql b/sql/sexps.sql
index 8279326..884e1f3 100644
--- a/sql/sexps.sql
+++ b/sql/sexps.sql
@@ -1,4 +1,4 @@
-- name: GetSingleExpenses :many
-SELECT id, description
+SELECT *
FROM single_expenses
WHERE user_id = $1; \ No newline at end of file