summaryrefslogtreecommitdiff
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/categories.sql.go48
-rw-r--r--model/models.go9
-rw-r--r--model/rexps.sql.go51
-rw-r--r--model/sexps.sql.go27
-rw-r--r--model/users.sql.go39
5 files changed, 156 insertions, 18 deletions
diff --git a/model/categories.sql.go b/model/categories.sql.go
new file mode 100644
index 0000000..c67e20d
--- /dev/null
+++ b/model/categories.sql.go
@@ -0,0 +1,48 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+// sqlc v1.25.0
+// source: categories.sql
+
+package model
+
+import (
+ "context"
+)
+
+const getCategoriesOrdered = `-- name: GetCategoriesOrdered :many
+SELECT id, name, parent_id, user_id
+ FROM categories
+ WHERE user_id = $1
+ ORDER BY name ASC
+`
+
+// GetCategoriesOrdered
+//
+// 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) ([]Category, error) {
+ rows, err := q.db.Query(ctx, getCategoriesOrdered, userID)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+ var items []Category
+ for rows.Next() {
+ var i Category
+ if err := rows.Scan(
+ &i.ID,
+ &i.Name,
+ &i.ParentID,
+ &i.UserID,
+ ); err != nil {
+ return nil, err
+ }
+ items = append(items, i)
+ }
+ if err := rows.Err(); err != nil {
+ return nil, err
+ }
+ return items, nil
+}
diff --git a/model/models.go b/model/models.go
index eba1207..b2a47dc 100644
--- a/model/models.go
+++ b/model/models.go
@@ -15,11 +15,11 @@ type Category struct {
UserID int32
}
-type ConstExpense struct {
+type RecurExpense struct {
ID int32
Description pgtype.Text
Expense pgtype.Numeric
- Months int16
+ Duration pgtype.Interval
Start pgtype.Date
End pgtype.Date
PrevID pgtype.Int4
@@ -31,9 +31,8 @@ type SingleExpense struct {
ID int64
Description pgtype.Text
Expense pgtype.Numeric
- Year int16
- Month int16
- Day int16
+ Date pgtype.Date
+ CorrMonth pgtype.Date
CategoryID int32
UserID int32
}
diff --git a/model/rexps.sql.go b/model/rexps.sql.go
new file mode 100644
index 0000000..9c3f1c0
--- /dev/null
+++ b/model/rexps.sql.go
@@ -0,0 +1,51 @@
+// Code generated by sqlc. DO NOT EDIT.
+// versions:
+// sqlc v1.25.0
+// source: rexps.sql
+
+package model
+
+import (
+ "context"
+)
+
+const getRecurExpenses = `-- name: GetRecurExpenses :many
+SELECT id, description, expense, duration, start, "end", prev_id, category_id, user_id
+ FROM recur_expenses
+ WHERE user_id = $1
+`
+
+// GetRecurExpenses
+//
+// 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) ([]RecurExpense, error) {
+ rows, err := q.db.Query(ctx, getRecurExpenses, userID)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+ var items []RecurExpense
+ for rows.Next() {
+ var i RecurExpense
+ if err := rows.Scan(
+ &i.ID,
+ &i.Description,
+ &i.Expense,
+ &i.Duration,
+ &i.Start,
+ &i.End,
+ &i.PrevID,
+ &i.CategoryID,
+ &i.UserID,
+ ); err != nil {
+ return nil, err
+ }
+ items = append(items, i)
+ }
+ if err := rows.Err(); err != nil {
+ return nil, err
+ }
+ return items, nil
+}
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/model/users.sql.go b/model/users.sql.go
index e63dacc..bd881b7 100644
--- a/model/users.sql.go
+++ b/model/users.sql.go
@@ -9,6 +9,24 @@ import (
"context"
)
+const getPwdById = `-- name: GetPwdById :one
+ SELECT pwd
+ FROM users
+ WHERE id = $1
+`
+
+// GetPwdById
+//
+// SELECT pwd
+// FROM users
+// WHERE id = $1
+func (q *Queries) GetPwdById(ctx context.Context, id int32) (string, error) {
+ row := q.db.QueryRow(ctx, getPwdById, id)
+ var pwd string
+ err := row.Scan(&pwd)
+ return pwd, err
+}
+
const getUserById = `-- name: GetUserById :one
SELECT id, name, pwd, description
FROM users
@@ -88,3 +106,24 @@ func (q *Queries) GetUsers(ctx context.Context) ([]User, error) {
}
return items, nil
}
+
+const updatePwd = `-- name: UpdatePwd :exec
+ UPDATE users
+ SET pwd = $1
+ WHERE id = $2
+`
+
+type UpdatePwdParams struct {
+ Pwd string
+ ID int32
+}
+
+// UpdatePwd
+//
+// UPDATE users
+// SET pwd = $1
+// WHERE id = $2
+func (q *Queries) UpdatePwd(ctx context.Context, arg UpdatePwdParams) error {
+ _, err := q.db.Exec(ctx, updatePwd, arg.Pwd, arg.ID)
+ return err
+}