store

package
v0.0.0-...-2db7ed4 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2018 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package store implements persistent data storage with clean API. Please note that time.Time values are always stored in UTC in the database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements the persistent storage

func From

func From(db *sql.DB) *Store

From creates the store from an existing db connection

func New

func New(driver, config string) *Store

New creates the store using the specified driver and db connection config

func NewTest

func NewTest() *Store

NewTest creates the store from a in-memory test database

func (*Store) CreateCountry

func (s *Store) CreateCountry(c *model.Country) error

func (*Store) CreateItem

func (s *Store) CreateItem(item *model.Item) error

func (*Store) CreateMarket

func (s *Store) CreateMarket(c *model.Market) error

func (*Store) GetCountry

func (s *Store) GetCountry(id int64) (*model.Country, error)

func (*Store) GetCountryByName

func (s *Store) GetCountryByName(name string) (*model.Country, error)

func (*Store) GetCurrency

func (s *Store) GetCurrency(code currency.Currency) (*model.Currency, error)

GetCurrency returns currency detail for specified currency code

func (*Store) GetCurrencyMultiplier

func (s *Store) GetCurrencyMultiplier(date time.Time, from currency.Currency, to currency.Currency) (float64, error)

GetCurrencyMultiplier finds multiplier for converting "from" currency to "to" currency. It does not check reverse record.

func (*Store) GetItem

func (s *Store) GetItem(id int64) (*model.Item, error)

GetItem returns item (company) by ID

func (*Store) GetItemByCode

func (s *Store) GetItemByCode(code string) (*model.Item, error)

func (*Store) GetMarket

func (s *Store) GetMarket(id int64) (*model.Market, error)

func (*Store) GetOrCreateCountry

func (s *Store) GetOrCreateCountry(name string) (*model.Country, error)

func (*Store) GetOrCreateCurrency

func (s *Store) GetOrCreateCurrency(code currency.Currency) (*model.Currency, error)

GetOrCreateCurrency returns currency detail or creates a new currency Nil is returned on error.

func (*Store) StoreCurrencyMultiplier

func (s *Store) StoreCurrencyMultiplier(date time.Time, from currency.Currency, to currency.Currency, mult float64) error

StoreCurrencyMultiplier stores multiplier for the specified date

func (*Store) UpdateCountry

func (s *Store) UpdateCountry(c *model.Country) error

func (*Store) UpdateItem

func (s *Store) UpdateItem(item *model.Item) error

func (*Store) UpdateMarket

func (s *Store) UpdateMarket(c *model.Market) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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