db

package
v0.0.0-...-285b632 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPrecision uint64 = 15

MaxPrexision denotes the maximum valid value for models.Security.Precision. This constant is used when storing amounts in securities into the database, so it must not be changed without appropriately migrating the database.

Variables

This section is empty.

Functions

func GetStore

func GetStore(dbtype config.DbType, dsn string) (store store.Store, err error)

Types

type DbStore

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

func (*DbStore) Begin

func (db *DbStore) Begin() (store.Tx, error)

func (*DbStore) Close

func (db *DbStore) Close() error

func (*DbStore) Empty

func (db *DbStore) Empty() error

type Price

type Price struct {
	PriceId         int64
	SecurityId      int64
	CurrencyId      int64
	Date            time.Time
	WholeValue      int64
	FractionalValue int64
	RemoteId        string // unique ID from source, for detecting duplicates
}

Price is a mirror of models.Price with the Value broken out into whole and fractional components

func NewPrice

func NewPrice(p *models.Price) (*Price, error)

func (Price) Price

func (p Price) Price() *models.Price

type Split

type Split struct {
	SplitId         int64
	TransactionId   int64
	Status          int64
	ImportSplitType int64

	// One of AccountId and SecurityId must be -1
	// In normal splits, AccountId will be valid and SecurityId will be -1. The
	// only case where this is reversed is for transactions that have been
	// imported and not yet associated with an account.
	AccountId  int64
	SecurityId int64

	RemoteId string // unique ID from server, for detecting duplicates
	Number   string // Check or reference number
	Memo     string

	// Amount.Whole and Amount.Fractional(MaxPrecision)
	WholeAmount      int64
	FractionalAmount int64
}

Split is a mirror of models.Split with the Amount broken out into whole and fractional components

func NewSplit

func NewSplit(s *models.Split) (*Split, error)

func (Split) Split

func (s Split) Split() *models.Split

type Tx

type Tx struct {
	Dialect gorp.Dialect
	Tx      *gorp.Transaction
}

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) Delete

func (tx *Tx) Delete(list ...interface{}) (int64, error)

func (*Tx) DeleteAccount

func (tx *Tx) DeleteAccount(account *models.Account) error

func (*Tx) DeletePrice

func (tx *Tx) DeletePrice(price *models.Price) error

func (*Tx) DeleteReport

func (tx *Tx) DeleteReport(report *models.Report) error

func (*Tx) DeleteSecurity

func (tx *Tx) DeleteSecurity(s *models.Security) error

func (*Tx) DeleteSession

func (tx *Tx) DeleteSession(session *models.Session) error

func (*Tx) DeleteTransaction

func (tx *Tx) DeleteTransaction(t *models.Transaction, user *models.User) error

func (*Tx) DeleteUser

func (tx *Tx) DeleteUser(user *models.User) error

func (*Tx) Exec

func (tx *Tx) Exec(query string, args ...interface{}) (sql.Result, error)

func (*Tx) FindMatchingAccounts

func (tx *Tx) FindMatchingAccounts(account *models.Account) (*[]*models.Account, error)

func (*Tx) FindMatchingSecurities

func (tx *Tx) FindMatchingSecurities(security *models.Security) (*[]*models.Security, error)

func (*Tx) GetAccount

func (tx *Tx) GetAccount(accountid int64, userid int64) (*models.Account, error)

func (*Tx) GetAccountBalance

func (tx *Tx) GetAccountBalance(user *models.User, accountid int64) (*models.Amount, error)

func (*Tx) GetAccountBalanceDate

func (tx *Tx) GetAccountBalanceDate(user *models.User, accountid int64, date *time.Time) (*models.Amount, error)

func (*Tx) GetAccountBalanceDateRange

func (tx *Tx) GetAccountBalanceDateRange(user *models.User, accountid int64, begin, end *time.Time) (*models.Amount, error)

func (*Tx) GetAccountTransactions

func (tx *Tx) GetAccountTransactions(user *models.User, accountid int64, sort string, page uint64, limit uint64) (*models.AccountTransactionsList, error)

func (*Tx) GetAccounts

func (tx *Tx) GetAccounts(userid int64) (*[]*models.Account, error)

func (*Tx) GetEarliestPrice

func (tx *Tx) GetEarliestPrice(security, currency *models.Security, date *time.Time) (*models.Price, error)

Return the earliest price for security in currency units after date

func (*Tx) GetLatestPrice

func (tx *Tx) GetLatestPrice(security, currency *models.Security, date *time.Time) (*models.Price, error)

Return the latest price for security in currency units before date

func (*Tx) GetPrice

func (tx *Tx) GetPrice(priceid, securityid int64) (*models.Price, error)

func (*Tx) GetPrices

func (tx *Tx) GetPrices(securityid int64) (*[]*models.Price, error)

func (*Tx) GetReport

func (tx *Tx) GetReport(reportid int64, userid int64) (*models.Report, error)

func (*Tx) GetReports

func (tx *Tx) GetReports(userid int64) (*[]*models.Report, error)

func (*Tx) GetSecurities

func (tx *Tx) GetSecurities(userid int64) (*[]*models.Security, error)

func (*Tx) GetSecurity

func (tx *Tx) GetSecurity(securityid int64, userid int64) (*models.Security, error)

func (*Tx) GetSession

func (tx *Tx) GetSession(secret string) (*models.Session, error)

func (*Tx) GetTransaction

func (tx *Tx) GetTransaction(transactionid int64, userid int64) (*models.Transaction, error)

func (*Tx) GetTransactions

func (tx *Tx) GetTransactions(userid int64) (*[]*models.Transaction, error)

func (*Tx) GetUser

func (tx *Tx) GetUser(userid int64) (*models.User, error)

func (*Tx) GetUserByUsername

func (tx *Tx) GetUserByUsername(username string) (*models.User, error)

func (*Tx) Insert

func (tx *Tx) Insert(list ...interface{}) error

func (*Tx) InsertAccount

func (tx *Tx) InsertAccount(account *models.Account) error

func (*Tx) InsertPrice

func (tx *Tx) InsertPrice(price *models.Price) error

func (*Tx) InsertReport

func (tx *Tx) InsertReport(report *models.Report) error

func (*Tx) InsertSecurity

func (tx *Tx) InsertSecurity(s *models.Security) error

func (*Tx) InsertSession

func (tx *Tx) InsertSession(session *models.Session) error

func (*Tx) InsertTransaction

func (tx *Tx) InsertTransaction(t *models.Transaction, user *models.User) error

func (*Tx) InsertUser

func (tx *Tx) InsertUser(user *models.User) error

func (*Tx) PriceExists

func (tx *Tx) PriceExists(price *models.Price) (bool, error)

func (*Tx) Rebind

func (tx *Tx) Rebind(query string) string

func (*Tx) Rollback

func (tx *Tx) Rollback() error

func (*Tx) Select

func (tx *Tx) Select(i interface{}, query string, args ...interface{}) ([]interface{}, error)

func (*Tx) SelectInt

func (tx *Tx) SelectInt(query string, args ...interface{}) (int64, error)

func (*Tx) SelectOne

func (tx *Tx) SelectOne(holder interface{}, query string, args ...interface{}) error

func (*Tx) SessionExists

func (tx *Tx) SessionExists(secret string) (bool, error)

func (*Tx) SplitExists

func (tx *Tx) SplitExists(s *models.Split) (bool, error)

func (*Tx) Update

func (tx *Tx) Update(list ...interface{}) (int64, error)

func (*Tx) UpdateAccount

func (tx *Tx) UpdateAccount(account *models.Account) error

func (*Tx) UpdatePrice

func (tx *Tx) UpdatePrice(price *models.Price) error

func (*Tx) UpdateReport

func (tx *Tx) UpdateReport(report *models.Report) error

func (*Tx) UpdateSecurity

func (tx *Tx) UpdateSecurity(security *models.Security) error

func (*Tx) UpdateTransaction

func (tx *Tx) UpdateTransaction(t *models.Transaction, user *models.User) error

func (*Tx) UpdateUser

func (tx *Tx) UpdateUser(user *models.User) error

func (*Tx) UsernameExists

func (tx *Tx) UsernameExists(username string) (bool, error)

Jump to

Keyboard shortcuts

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