db

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotFoundError

func IsNotFoundError(err error) bool

func IsUniqueViolationError

func IsUniqueViolationError(err error) bool

Types

type AccountRepository

type AccountRepository struct {
	// contains filtered or unexported fields
}

func NewAccountRepository

func NewAccountRepository(db *sql.DB) *AccountRepository

func (*AccountRepository) CreateAccount

func (r *AccountRepository) CreateAccount(ctx context.Context, params core.CreateAccountParams) error

CreateAccount creates an account for a user

func (*AccountRepository) DeleteAccount

func (r *AccountRepository) DeleteAccount(ctx context.Context, accountID int64) error

DeleteAccount deletes account by given id

func (*AccountRepository) GetAccount

func (r *AccountRepository) GetAccount(ctx context.Context, accountID int64) (core.Account, error)

GetAccount returns account for given account id

func (*AccountRepository) GetAccounts

func (r *AccountRepository) GetAccounts(ctx context.Context, userID int64) ([]core.Account, error)

GetAccounts returns all accounts for given user

type CardRepository

type CardRepository struct {
	// contains filtered or unexported fields
}

func NewCardRepository

func NewCardRepository(db *sql.DB) *CardRepository

func (*CardRepository) CreateCard

func (r *CardRepository) CreateCard(ctx context.Context, params core.CreateCardParams) error

CreateCard creates a new card in the database

func (*CardRepository) DeleteCard

func (r *CardRepository) DeleteCard(ctx context.Context, cardNumber string) error

DeleteCard deletes a card for a given number

func (*CardRepository) GetCard

func (r *CardRepository) GetCard(ctx context.Context, cardNumber string) (core.Card, error)

GetCard returns a card for a given number

func (*CardRepository) GetCardAccount

func (r *CardRepository) GetCardAccount(ctx context.Context, cardNumber string) (core.Account, error)

func (*CardRepository) GetCards

func (r *CardRepository) GetCards(ctx context.Context, accountID int64) ([]core.Card, error)

GetCards returns all cards for a given account

type TransactionRepository

type TransactionRepository struct {
	// contains filtered or unexported fields
}

func NewTransactionRepository

func NewTransactionRepository(db *sql.DB) *TransactionRepository

func (*TransactionRepository) Deposit

Deposit adds money to an account and creates a transaction

func (*TransactionRepository) GetTransaction

func (r *TransactionRepository) GetTransaction(ctx context.Context, transactionID uuid.UUID) (core.Transaction, error)

GetTransaction returns a transaction by its ID

func (*TransactionRepository) GetTransactions

GetTransactions returns a list of transactions for a given account with filters(pagination, date range, etc)

func (*TransactionRepository) RollbackTransaction

func (r *TransactionRepository) RollbackTransaction(ctx context.Context, transactionID uuid.UUID) error

RollbackTransaction deletes a transaction and restores the balance of the involved accounts

func (*TransactionRepository) Transfer

Transfer transfers money from one account to another

func (*TransactionRepository) Withdraw

Withdraw subtracts money from an account and creates a transaction

type UserRepository

type UserRepository struct {
	// contains filtered or unexported fields
}

func NewUserRepository

func NewUserRepository(db *sql.DB) *UserRepository

func (*UserRepository) CreateUser

func (r *UserRepository) CreateUser(ctx context.Context, uuid uuid.UUID) error

CreateUser creates a new user in the database with the given uuid

func (*UserRepository) GetUser

func (r *UserRepository) GetUser(ctx context.Context, uuid uuid.UUID) (int64, error)

GetUser returns the user id for the given uuid, Where uuid is the global user id between services

Directories

Path Synopsis
sql

Jump to

Keyboard shortcuts

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