expenserepo

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildExpenseListOrderByClause

func BuildExpenseListOrderByClause(ascending bool, field string) string

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

func BuildLimitClause(limit int, params *[]interface{}) string

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.

Jump to

Keyboard shortcuts

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