summaryrefslogtreecommitdiff
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/db.go (renamed from model/db_sqlite.go)2
-rw-r--r--model/db_mysql.go33
-rw-r--r--model/models.go (renamed from model/models_mysql.go)14
-rw-r--r--model/models_sqlite.go49
-rw-r--r--model/sexps.sql.go (renamed from model/sexps.sql.mysql.go)2
-rw-r--r--model/sexps.sql.sqlite.go52
-rw-r--r--model/users.sql.go (renamed from model/users.sql.mysql.go)2
-rw-r--r--model/users.sql.sqlite.go95
8 files changed, 6 insertions, 243 deletions
diff --git a/model/db_sqlite.go b/model/db.go
index 97e8f76..2e42192 100644
--- a/model/db_sqlite.go
+++ b/model/db.go
@@ -1,5 +1,3 @@
-//go:build sqlite
-
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
diff --git a/model/db_mysql.go b/model/db_mysql.go
deleted file mode 100644
index b236214..0000000
--- a/model/db_mysql.go
+++ /dev/null
@@ -1,33 +0,0 @@
-//go:build !sqlite
-
-// Code generated by sqlc. DO NOT EDIT.
-// versions:
-// sqlc v1.25.0
-
-package model
-
-import (
- "context"
- "database/sql"
-)
-
-type DBTX interface {
- ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
- PrepareContext(context.Context, string) (*sql.Stmt, error)
- QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
- QueryRowContext(context.Context, string, ...interface{}) *sql.Row
-}
-
-func New(db DBTX) *Queries {
- return &Queries{db: db}
-}
-
-type Queries struct {
- db DBTX
-}
-
-func (q *Queries) WithTx(tx *sql.Tx) *Queries {
- return &Queries{
- db: tx,
- }
-}
diff --git a/model/models_mysql.go b/model/models.go
index 359e583..be09076 100644
--- a/model/models_mysql.go
+++ b/model/models.go
@@ -1,5 +1,3 @@
-//go:build !sqlite
-
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
@@ -22,23 +20,23 @@ type ConstExpense struct {
ID int32
Description sql.NullString
Expense string
- Months int32
+ Months uint8
Start time.Time
End time.Time
PrevID sql.NullInt32
- UserID int32
CategoryID int32
+ UserID int32
}
type SingleExpense struct {
ID int32
Description sql.NullString
Expense string
- Year int32
- Month int32
- Day int32
- UserID int32
+ Year uint16
+ Month uint8
+ Day uint8
CategoryID int32
+ UserID int32
}
type User struct {
diff --git a/model/models_sqlite.go b/model/models_sqlite.go
deleted file mode 100644
index 892cdd7..0000000
--- a/model/models_sqlite.go
+++ /dev/null
@@ -1,49 +0,0 @@
-//go:build sqlite
-
-// Code generated by sqlc. DO NOT EDIT.
-// versions:
-// sqlc v1.25.0
-
-package model
-
-import (
- "database/sql"
- "time"
-)
-
-type Category struct {
- ID int64
- Name string
- ParentID sql.NullInt64
- UserID int64
-}
-
-type ConstExpense struct {
- ID int64
- Description sql.NullString
- Expense interface{}
- Months int64
- Start time.Time
- End time.Time
- PrevID sql.NullInt64
- UserID int64
- CategoryID int64
-}
-
-type SingleExpense struct {
- ID int64
- Description sql.NullString
- Expense interface{}
- Year int64
- Month int64
- Day int64
- UserID int64
- CategoryID int64
-}
-
-type User struct {
- ID int64
- Name string
- Pwd string
- Description sql.NullString
-}
diff --git a/model/sexps.sql.mysql.go b/model/sexps.sql.go
index 70bc93e..1108e55 100644
--- a/model/sexps.sql.mysql.go
+++ b/model/sexps.sql.go
@@ -1,5 +1,3 @@
-//go:build !sqlite
-
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
diff --git a/model/sexps.sql.sqlite.go b/model/sexps.sql.sqlite.go
deleted file mode 100644
index 6853390..0000000
--- a/model/sexps.sql.sqlite.go
+++ /dev/null
@@ -1,52 +0,0 @@
-//go:build sqlite
-
-// Code generated by sqlc. DO NOT EDIT.
-// versions:
-// sqlc v1.25.0
-// source: sexps.sql
-
-package model
-
-import (
- "context"
- "database/sql"
-)
-
-const getSingleExpenses = `-- name: GetSingleExpenses :many
-SELECT id, description
- FROM single_expenses
- WHERE user_id = ?
-`
-
-type GetSingleExpensesRow struct {
- ID int64
- Description sql.NullString
-}
-
-// GetSingleExpenses
-//
-// SELECT id, description
-// FROM single_expenses
-// WHERE user_id = ?
-func (q *Queries) GetSingleExpenses(ctx context.Context, userID int64) ([]GetSingleExpensesRow, error) {
- rows, err := q.db.QueryContext(ctx, getSingleExpenses, userID)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- var items []GetSingleExpensesRow
- for rows.Next() {
- var i GetSingleExpensesRow
- if err := rows.Scan(&i.ID, &i.Description); err != nil {
- return nil, err
- }
- items = append(items, i)
- }
- if err := rows.Close(); err != nil {
- return nil, err
- }
- if err := rows.Err(); err != nil {
- return nil, err
- }
- return items, nil
-}
diff --git a/model/users.sql.mysql.go b/model/users.sql.go
index acc462d..87ae961 100644
--- a/model/users.sql.mysql.go
+++ b/model/users.sql.go
@@ -1,5 +1,3 @@
-//go:build !sqlite
-
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
diff --git a/model/users.sql.sqlite.go b/model/users.sql.sqlite.go
deleted file mode 100644
index 4662ca4..0000000
--- a/model/users.sql.sqlite.go
+++ /dev/null
@@ -1,95 +0,0 @@
-//go:build sqlite
-
-// Code generated by sqlc. DO NOT EDIT.
-// versions:
-// sqlc v1.25.0
-// source: users.sql
-
-package model
-
-import (
- "context"
-)
-
-const getUserById = `-- name: GetUserById :one
-SELECT id, name, pwd, description
- FROM users
- WHERE id = ?
-`
-
-// GetUserById
-//
-// SELECT id, name, pwd, description
-// FROM users
-// WHERE id = ?
-func (q *Queries) GetUserById(ctx context.Context, id int64) (User, error) {
- row := q.db.QueryRowContext(ctx, getUserById, id)
- var i User
- err := row.Scan(
- &i.ID,
- &i.Name,
- &i.Pwd,
- &i.Description,
- )
- return i, err
-}
-
-const getUserByName = `-- name: GetUserByName :one
-SELECT id, name, pwd, description
- FROM users
- WHERE LOWER(name) = LOWER(?)
-`
-
-// GetUserByName
-//
-// SELECT id, name, pwd, description
-// FROM users
-// WHERE LOWER(name) = LOWER(?)
-func (q *Queries) GetUserByName(ctx context.Context, lower string) (User, error) {
- row := q.db.QueryRowContext(ctx, getUserByName, lower)
- var i User
- err := row.Scan(
- &i.ID,
- &i.Name,
- &i.Pwd,
- &i.Description,
- )
- return i, err
-}
-
-const getUsers = `-- name: GetUsers :many
-SELECT id, name, pwd, description
- FROM users
-`
-
-// GetUsers
-//
-// SELECT id, name, pwd, description
-// FROM users
-func (q *Queries) GetUsers(ctx context.Context) ([]User, error) {
- rows, err := q.db.QueryContext(ctx, getUsers)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- var items []User
- for rows.Next() {
- var i User
- if err := rows.Scan(
- &i.ID,
- &i.Name,
- &i.Pwd,
- &i.Description,
- ); err != nil {
- return nil, err
- }
- items = append(items, i)
- }
- if err := rows.Close(); err != nil {
- return nil, err
- }
- if err := rows.Err(); err != nil {
- return nil, err
- }
- return items, nil
-}