Documentation ¶
Index ¶
- func NewConnection(ctx context.Context, cfg config.Postgres) (*pgx.Conn, error)
- type AccountsRepository
- func (r AccountsRepository) CreateAccount(ctx context.Context, acc entities.Account) (vos.AccountID, error)
- func (r AccountsRepository) DecreaseAvailableCredit(ctx context.Context, accID vos.AccountID, amount vos.Money) error
- func (r AccountsRepository) Deposit(ctx context.Context, accID vos.AccountID, amount vos.Money) error
- func (r AccountsRepository) GetAccountByID(ctx context.Context, accID vos.AccountID) (entities.Account, error)
- func (r AccountsRepository) Withdraw(ctx context.Context, accID vos.AccountID, amount vos.Money) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccountsRepository ¶
type AccountsRepository struct {
// contains filtered or unexported fields
}
AccountsRepository is the repository of accounts
func NewAccountsRepository ¶
func NewAccountsRepository(conn *pgx.Conn) *AccountsRepository
NewAccountsRepository returns an acc repository
func (AccountsRepository) CreateAccount ¶
func (r AccountsRepository) CreateAccount(ctx context.Context, acc entities.Account) (vos.AccountID, error)
CreateAccount inserts an account on DB returning its ID
func (AccountsRepository) DecreaseAvailableCredit ¶
func (r AccountsRepository) DecreaseAvailableCredit(ctx context.Context, accID vos.AccountID, amount vos.Money) error
DecreaseAvailableCredit decreases account available credit
func (AccountsRepository) Deposit ¶
func (r AccountsRepository) Deposit(ctx context.Context, accID vos.AccountID, amount vos.Money) error
Deposit increments account balance
func (AccountsRepository) GetAccountByID ¶
func (r AccountsRepository) GetAccountByID(ctx context.Context, accID vos.AccountID) (entities.Account, error)
GetAccountByID retrieves an account by ID
Click to show internal directories.
Click to hide internal directories.