Documentation ¶
Index ¶
- type DB
- type MasterRepository
- func (repo *MasterRepository) FindCategoryByID(ctx context.Context, id string) (*domain.Category, error)
- func (repo *MasterRepository) FindCategoryByNameAndLevel(ctx context.Context, name string, level domain.CategoryLevel) (*domain.Category, error)
- func (repo *MasterRepository) FindOrCreateCategory(ctx context.Context, name string, level domain.CategoryLevel, parentID string) (*domain.Category, error)
- func (repo *MasterRepository) FindOrCreateSource(ctx context.Context, name string) (*domain.Source, error)
- func (repo *MasterRepository) FindSourceByName(ctx context.Context, name string) (*domain.Source, error)
- type MoneyForwardRepository
- type StatsRepository
- type Transaction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { Exec(query string, args ...interface{}) (sql.Result, error) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) Prepare(query string) (*sql.Stmt, error) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row }
DB is an interface for DB and Tx of database/sql
type MasterRepository ¶
type MasterRepository struct {
// contains filtered or unexported fields
}
MasterRepository is a database repository for master data.
func NewMasterRepository ¶
func NewMasterRepository(transaction *Transaction) *MasterRepository
NewMasterRepository returns a new MasterRepository.
func (*MasterRepository) FindCategoryByID ¶
func (repo *MasterRepository) FindCategoryByID(ctx context.Context, id string) (*domain.Category, error)
FindCategoryByID finds the category by id.
func (*MasterRepository) FindCategoryByNameAndLevel ¶
func (repo *MasterRepository) FindCategoryByNameAndLevel(ctx context.Context, name string, level domain.CategoryLevel) (*domain.Category, error)
FindCategoryByNameAndLevel finds the category by name and level.
func (*MasterRepository) FindOrCreateCategory ¶
func (repo *MasterRepository) FindOrCreateCategory(ctx context.Context, name string, level domain.CategoryLevel, parentID string) (*domain.Category, error)
FindOrCreateCategory finds or creates a category.
func (*MasterRepository) FindOrCreateSource ¶
func (repo *MasterRepository) FindOrCreateSource(ctx context.Context, name string) (*domain.Source, error)
FindOrCreateSource finds or creates a source.
func (*MasterRepository) FindSourceByName ¶
func (repo *MasterRepository) FindSourceByName(ctx context.Context, name string) (*domain.Source, error)
FindSourceByName finds the source by name.
type MoneyForwardRepository ¶
type MoneyForwardRepository struct {
// contains filtered or unexported fields
}
MoneyForwardRepository is a database repository for money forward data.
func NewMoneyForwardRepository ¶
func NewMoneyForwardRepository(transaction *Transaction) *MoneyForwardRepository
NewMoneyForwardRepository returns a new MoneyForwardRepository.
func (*MoneyForwardRepository) CreateOrUpdateRecord ¶
func (repo *MoneyForwardRepository) CreateOrUpdateRecord(ctx context.Context, record *domain.MoneyForwardRecord) error
CreateOrUpdateRecord creates or updates a money forward record.
func (*MoneyForwardRepository) FindRecord ¶
func (repo *MoneyForwardRepository) FindRecord(ctx context.Context, id string) (*domain.MoneyForwardRecord, error)
FindRecord finds the record by id.
type StatsRepository ¶
type StatsRepository struct {
// contains filtered or unexported fields
}
StatsRepository is a database repository for statistics.
func NewStatsRepository ¶
func NewStatsRepository(transaction *Transaction) *StatsRepository
NewStatsRepository returns a new StatsRepository.
func (*StatsRepository) FindExpensesByMonthAndCategoryInYear ¶
func (repo *StatsRepository) FindExpensesByMonthAndCategoryInYear(ctx context.Context, year int) ([]*domain.AmountByYearMonthCategory, error)
FindExpensesByMonthAndCategoryInYear finds expenses group by month and category for given year.
func (*StatsRepository) FindExpensesByMonthInYear ¶
func (repo *StatsRepository) FindExpensesByMonthInYear(ctx context.Context, year int) ([]*domain.AmountByYearMonth, error)
FindExpensesByMonthInYear finds expenses group by month for given year.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction manages *sql.DB and current *sql.Tx
func NewTransaction ¶
func NewTransaction(db *sql.DB) *Transaction
NewTransaction returns a new transaction.
func (*Transaction) Begin ¶
func (tx *Transaction) Begin(ctx context.Context) error
Begin starts a transaction.