database

package
v0.0.0-...-ccf00c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Budget

type Budget struct {
	ID              int
	MonthID         int
	Category        Category
	Amount          float64
	TransactionType TransactionType
	CreatedAt       time.Time
	UpdatedAt       sql.NullTime
}

type BudgetItem

type BudgetItem struct {
	BudgetID        int
	MonthID         int
	Category        Category
	TransactionType TransactionType
	Planned         float64
	Actual          float64
}

type Category

type Category string
const (
	CategoryBonus          Category = "bonus"
	CategoryCashback       Category = "cashback"
	CategoryFood           Category = "food"
	CategoryGifts          Category = "gifts"
	CategoryHome           Category = "home"
	CategoryInterest       Category = "interest"
	CategoryMedical        Category = "medical"
	CategoryOther          Category = "other"
	CategoryPaycheck       Category = "paycheck"
	CategoryPersonal       Category = "personal"
	CategorySavings        Category = "savings"
	CategoryTransportation Category = "transportation"
	CategoryTravel         Category = "travel"
	CategoryUtilities      Category = "utilities"
)

func AllCategoryValues

func AllCategoryValues() []Category

func (*Category) Scan

func (e *Category) Scan(src interface{}) error

type CreateMonthParams

type CreateMonthParams struct {
	Month time.Month
	Year  int
}

type CreateTransactionParams

type CreateTransactionParams struct {
	Description     string
	Amount          float64
	Date            time.Time
	Category        Category
	TransactionType TransactionType
}

type DBTX

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
}

type GetBudgetItemsByMonthIDAndTransactionTypeParams

type GetBudgetItemsByMonthIDAndTransactionTypeParams struct {
	MonthID         int
	TransactionType TransactionType
}

type GetMonthByMonthAndYearParams

type GetMonthByMonthAndYearParams struct {
	Month time.Month
	Year  int
}

type GetTransactionsByMonthIDAndTypeParams

type GetTransactionsByMonthIDAndTypeParams struct {
	ID              int
	TransactionType TransactionType
}

type Month

type Month struct {
	ID        int
	Year      int
	Month     time.Month
	CreatedAt time.Time
	UpdatedAt sql.NullTime
}

type NullCategory

type NullCategory struct {
	Category Category
	Valid    bool // Valid is true if Category is not NULL
}

func (*NullCategory) Scan

func (ns *NullCategory) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullCategory) Value

func (ns NullCategory) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullTransactionType

type NullTransactionType struct {
	TransactionType TransactionType
	Valid           bool // Valid is true if TransactionType is not NULL
}

func (*NullTransactionType) Scan

func (ns *NullTransactionType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTransactionType) Value

func (ns NullTransactionType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type PatchBudgetParams

type PatchBudgetParams struct {
	Amount float64
	ID     int
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CreateMonth

func (q *Queries) CreateMonth(ctx context.Context, arg CreateMonthParams) (Month, error)

func (*Queries) CreateNewBudgetsForMonth

func (q *Queries) CreateNewBudgetsForMonth(ctx context.Context, monthID int) ([]Budget, error)

func (*Queries) CreateTransaction

func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionParams) (Transaction, error)

func (*Queries) DeleteTransaction

func (q *Queries) DeleteTransaction(ctx context.Context, id int) error

func (*Queries) GetAllMonths

func (q *Queries) GetAllMonths(ctx context.Context) ([]Month, error)

func (*Queries) GetBudgetItemsByMonthIDAndTransactionType

func (q *Queries) GetBudgetItemsByMonthIDAndTransactionType(ctx context.Context, arg GetBudgetItemsByMonthIDAndTransactionTypeParams) ([]BudgetItem, error)

func (*Queries) GetMonthByID

func (q *Queries) GetMonthByID(ctx context.Context, id int) (Month, error)

func (*Queries) GetMonthByMonthAndYear

func (q *Queries) GetMonthByMonthAndYear(ctx context.Context, arg GetMonthByMonthAndYearParams) (Month, error)

func (*Queries) GetTransactionsByMonthIDAndType

func (q *Queries) GetTransactionsByMonthIDAndType(ctx context.Context, arg GetTransactionsByMonthIDAndTypeParams) ([]Transaction, error)

func (*Queries) PatchBudget

func (q *Queries) PatchBudget(ctx context.Context, arg PatchBudgetParams) (Budget, error)

func (*Queries) UpdateTransaction

func (q *Queries) UpdateTransaction(ctx context.Context, arg UpdateTransactionParams) (Transaction, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Transaction

type Transaction struct {
	ID              int
	Date            time.Time
	Amount          float64
	Description     string
	Category        Category
	TransactionType TransactionType
	CreatedAt       time.Time
	UpdatedAt       sql.NullTime
}

type TransactionType

type TransactionType string
const (
	TransactionTypeExpense TransactionType = "expense"
	TransactionTypeIncome  TransactionType = "income"
)

func AllTransactionTypeValues

func AllTransactionTypeValues() []TransactionType

func (*TransactionType) Scan

func (e *TransactionType) Scan(src interface{}) error

type UpdateTransactionParams

type UpdateTransactionParams struct {
	Description     string
	Amount          float64
	Date            time.Time
	Category        Category
	TransactionType TransactionType
	ID              int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL