Documentation ¶
Index ¶
- type BoltDataSource
- func (ds *BoltDataSource) AddEntry(entryDate string, calories int, food string) error
- func (ds *BoltDataSource) AddWeight(weight float64) error
- func (ds *BoltDataSource) CurrentWeight() (*model.Weight, error)
- func (ds *BoltDataSource) Export() (*model.ImpEx, error)
- func (ds *BoltDataSource) FetchAllEntries() (model.Entries, error)
- func (ds *BoltDataSource) FetchConfig() (config *model.Config, err error)
- func (ds *BoltDataSource) FetchEntries(entryDate string) (model.Entries, error)
- func (ds *BoltDataSource) FetchWeights() ([]model.Weight, error)
- func (ds *BoltDataSource) Import(data *model.ImpEx) error
- func (ds *BoltDataSource) RemoveEntries(entryDate string) error
- func (ds *BoltDataSource) RemoveEntry(entryDate string, id int) error
- func (ds *BoltDataSource) SetConfig(c *model.Config) error
- func (ds *BoltDataSource) SetConfigFromImport(c *model.Config) error
- func (ds *BoltDataSource) Setup(connection string) (func() error, error)
- type DataSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoltDataSource ¶
BoltDataSource is an implementation of the DataSource interface for boltdb
func (*BoltDataSource) AddEntry ¶
func (ds *BoltDataSource) AddEntry(entryDate string, calories int, food string) error
AddEntry fetches the current config and weight to calculate the metabolic rate and adds the data into the entry table
func (*BoltDataSource) AddWeight ¶
func (ds *BoltDataSource) AddWeight(weight float64) error
AddWeight adds the given weight for todays date
func (*BoltDataSource) CurrentWeight ¶
func (ds *BoltDataSource) CurrentWeight() (*model.Weight, error)
CurrentWeight fetches and returns the current weight, which is the last entry in the table
func (*BoltDataSource) Export ¶
func (ds *BoltDataSource) Export() (*model.ImpEx, error)
Export creates a JSON representation of the database
func (*BoltDataSource) FetchAllEntries ¶
func (ds *BoltDataSource) FetchAllEntries() (model.Entries, error)
FetchAllEntries fetches and returns all entries
func (*BoltDataSource) FetchConfig ¶
func (ds *BoltDataSource) FetchConfig() (config *model.Config, err error)
FetchConfig fetches and returns the current config
func (*BoltDataSource) FetchEntries ¶
func (ds *BoltDataSource) FetchEntries(entryDate string) (model.Entries, error)
FetchEntries fetches and returns all entries for a given date
func (*BoltDataSource) FetchWeights ¶
func (ds *BoltDataSource) FetchWeights() ([]model.Weight, error)
FetchWeights fetches all weight entries
func (*BoltDataSource) Import ¶
func (ds *BoltDataSource) Import(data *model.ImpEx) error
Import imports the given data to the database, overwriting the previous data
func (*BoltDataSource) RemoveEntries ¶
func (ds *BoltDataSource) RemoveEntries(entryDate string) error
RemoveEntries removes all entries for a given day from the database
func (*BoltDataSource) RemoveEntry ¶
func (ds *BoltDataSource) RemoveEntry(entryDate string, id int) error
RemoveEntry removes the entry with the given id for a given day from the database
func (*BoltDataSource) SetConfig ¶
func (ds *BoltDataSource) SetConfig(c *model.Config) error
SetConfig overrides the current config with the given values by deleting the old config and adding a new one
func (*BoltDataSource) SetConfigFromImport ¶
func (ds *BoltDataSource) SetConfigFromImport(c *model.Config) error
SetConfigFromImport overrides the current config with the given values by deleting the old config and adding a new one
type DataSource ¶
type DataSource interface { Setup(connection string) (func() error, error) SetConfig(*model.Config) error SetConfigFromImport(*model.Config) error FetchConfig() (*model.Config, error) AddWeight(weight float64) error CurrentWeight() (*model.Weight, error) FetchWeights() ([]model.Weight, error) AddEntry(entryDate string, calories int, food string) error FetchEntries(entryDate string) (model.Entries, error) FetchAllEntries() (model.Entries, error) RemoveEntries(entryDate string) error RemoveEntry(entryDate string, id int) error Import(data *model.ImpEx) error Export() (*model.ImpEx, error) }
DataSource is the interface to the data layer