Documentation ¶
Overview ¶
Package expenserepo provides the implementation of the IExpenseRepository interface for managing expenses in a PostgreSQL database.
Package expenserepo provides utilities for working with expense models and building SQL queries.
Index ¶
- func BuildExpenseListOrderByClause(ascending bool, field string) string
- func BuildExpenseListWhereClause(ascending bool, id uuid.UUID, value interface{}, field string, ...) string
- func BuildLimitClause(limit int, params *[]interface{}) string
- func ScanExpense(scanner interface{ ... }) (*expensemodel.Expense, error)
- type Repository
- func (e *Repository) ById(id uuid.UUID, userId uuid.UUID) (*expensemodel.Expense, error)
- func (e *Repository) ListByAmount(params irepository.ListByAmountParams) ([]*expensemodel.Expense, error)
- func (e *Repository) ListByTime(params irepository.ListByTimeParams) ([]*expensemodel.Expense, error)
- func (e *Repository) Save(expense *expensemodel.Expense) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildExpenseListOrderByClause ¶
BuildExpenseListOrderByClause creates the ORDER BY clause for expense pagination queries.
func BuildExpenseListWhereClause ¶
func BuildExpenseListWhereClause(ascending bool, id uuid.UUID, value interface{}, field string, params *[]interface{}) string
BuildExpenseListWhereClause creates the WHERE clause for expense pagination queries.
func BuildLimitClause ¶
BuildLimitClause creates the LIMIT clause for expense pagination queries.
func ScanExpense ¶
func ScanExpense(scanner interface { Scan(dest ...interface{}) error }) (*expensemodel.Expense, error)
ScanExpense converts a database row into an Expense model.
Types ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository implements the IExpenseRepository interface for interacting with the expenses table in the database.
func New ¶
func New(db *sql.DB) *Repository
New creates a new instance of Repository with the given database connection.
func (*Repository) ById ¶
func (e *Repository) ById(id uuid.UUID, userId uuid.UUID) (*expensemodel.Expense, error)
ById retrieves an expense by its unique identifier and user ID.
func (*Repository) ListByAmount ¶
func (e *Repository) ListByAmount(params irepository.ListByAmountParams) ([]*expensemodel.Expense, error)
ListByAmount retrieves paginated expenses for a user based on amount.
func (*Repository) ListByTime ¶
func (e *Repository) ListByTime(params irepository.ListByTimeParams) ([]*expensemodel.Expense, error)
ListByTime retrieves paginated expenses for a user based on creation time.
func (*Repository) Save ¶
func (e *Repository) Save(expense *expensemodel.Expense) error
Save inserts or updates an expense in the database.