db

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: Apache-2.0, BSD-2-Clause-Views, MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

type Driver interface {
	Init(url string) (err error)
	DB() *sqlx.DB
	MigrateUp(component string) (migrationsApplied int, err error)

	Insert(object entities.Entity) (id int64, err error)
	Update(object entities.Entity) (err error)
	Delete(object entities.Entity) (err error)

	GetOne(object entities.Entity, where string, params ...interface{}) (entities.Entity, error)
	GetMany(slice interface{}, where, order, offset, limit *string, params ...interface{}) (err error)
}

Driver interface allows mocking database driver

type EntityManager

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

EntityManager is responsible for persisting object to DB

func NewEntityManager

func NewEntityManager(driver Driver) (em EntityManager)

NewEntityManager creates a new EntityManager using driver

func (EntityManager) Delete

func (em EntityManager) Delete(object entities.Entity) error

Delete an object from DB.

func (EntityManager) Persist

func (em EntityManager) Persist(object entities.Entity) (err error)

Persist persists an object in DB.

If `object.IsNew()` equals true object will be inserted. Otherwise, it will found using `object.GetId()` and updated.

type EntityManagerInterface

type EntityManagerInterface interface {
	Delete(object entities.Entity) (err error)
	Persist(object entities.Entity) error
}

EntityManagerInterface allows mocking EntityManager

type Repository

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

Repository helps getting data from DB

func NewRepository

func NewRepository(driver Driver) (r Repository)

NewRepository creates a new Repository using driver

func (Repository) GetAllowedFiByDomain

func (r Repository) GetAllowedFiByDomain(domain string) (*entities.AllowedFi, error)

GetAllowedFiByDomain returns allowed FI by a domain

func (Repository) GetAllowedUserByDomainAndUserID

func (r Repository) GetAllowedUserByDomainAndUserID(domain, userID string) (*entities.AllowedUser, error)

GetAllowedUserByDomainAndUserID returns allowed user by domain and userID

func (Repository) GetAuthData added in v0.0.31

func (r Repository) GetAuthData(requestID string) (*entities.AuthData, error)

GetAuthData returns received auth data by request_id

func (Repository) GetAuthorizedTransactionByMemo

func (r Repository) GetAuthorizedTransactionByMemo(memo string) (*entities.AuthorizedTransaction, error)

GetAuthorizedTransactionByMemo returns authorized transaction searching by memo

func (Repository) GetLastCursorValue

func (r Repository) GetLastCursorValue() (cursor *string, err error)

GetLastCursorValue returns last cursor value from a DB

func (Repository) GetReceivedPaymentByOperationID added in v0.0.22

func (r Repository) GetReceivedPaymentByOperationID(operationID int64) (*entities.ReceivedPayment, error)

GetReceivedPaymentByOperationID returns received payment by operation_id

func (Repository) GetReceivedPayments added in v0.0.27

func (r Repository) GetReceivedPayments(page, limit int) ([]*entities.ReceivedPayment, error)

GetReceivedPayments returns received payments

func (Repository) GetSentTransactionByPaymentID added in v0.0.29

func (r Repository) GetSentTransactionByPaymentID(paymentID string) (*entities.SentTransaction, error)

GetSentTransactionByPaymentID returns sent transaction searching by payment ID

func (Repository) GetSentTransactions added in v0.0.27

func (r Repository) GetSentTransactions(page, limit int) ([]*entities.SentTransaction, error)

GetSentTransactions returns received payments

type RepositoryInterface

type RepositoryInterface interface {
	GetLastCursorValue() (cursor *string, err error)
	GetAuthorizedTransactionByMemo(memo string) (*entities.AuthorizedTransaction, error)
	GetSentTransactionByPaymentID(paymentID string) (*entities.SentTransaction, error)
	GetAllowedFiByDomain(domain string) (*entities.AllowedFi, error)
	GetAllowedUserByDomainAndUserID(domain, userID string) (*entities.AllowedUser, error)
	GetAuthData(requestID string) (*entities.AuthData, error)
	GetReceivedPaymentByOperationID(operationID int64) (*entities.ReceivedPayment, error)
	GetReceivedPayments(page, limit int) ([]*entities.ReceivedPayment, error)
	GetSentTransactions(page, limit int) ([]*entities.SentTransaction, error)
}

RepositoryInterface helps mocking Repository

Directories

Path Synopsis
drivers

Jump to

Keyboard shortcuts

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