postgres

package
v0.0.0-...-386fda5 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

func NewConnection(ctx context.Context, cfg config.Postgres) (*pgx.Conn, error)

NewConnection sets up a new connection with migrations

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

func (AccountsRepository) Withdraw

func (r AccountsRepository) Withdraw(ctx context.Context, accID vos.AccountID, amount vos.Money) error

Withdraw decreases account balance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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