Documentation ¶
Index ¶
- type AccountModel
- type BottleModel
- type DB
- func (db *DB) DeleteAccount(model AccountModel)
- func (db *DB) DeleteBottle(model BottleModel)
- func (db *DB) GetAccount(id int) (model AccountModel, ok bool)
- func (db *DB) GetAccounts() []AccountModel
- func (db *DB) GetBottle(account, id int) (model BottleModel, ok bool)
- func (db *DB) GetBottles(account int) ([]BottleModel, error)
- func (db *DB) GetBottlesByYears(account int, years []int) ([]BottleModel, error)
- func (db *DB) NewAccount() (model AccountModel)
- func (db *DB) NewBottle(account int) (model BottleModel, err error)
- func (db *DB) Reset()
- func (db *DB) SaveAccount(model AccountModel)
- func (db *DB) SaveBottle(model BottleModel)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountModel ¶
AccountModel is the database "model" for accounts
type BottleModel ¶
type BottleModel struct { ID int AccountID int Name string Kind string Color string Country *string CreatedAt time.Time Rating *int Region *string Review *string Sweetness *int UpdatedAt time.Time Varietal string Vineyard string Vintage int }
BottleModel is the database "model" for bottles
type DB ¶
DB emulates a database driver using in-memory data structures.
func (*DB) DeleteAccount ¶
func (db *DB) DeleteAccount(model AccountModel)
DeleteAccount deletes the account.
func (*DB) DeleteBottle ¶
func (db *DB) DeleteBottle(model BottleModel)
DeleteBottle deletes bottle from bottlesbase.
func (*DB) GetAccount ¶
func (db *DB) GetAccount(id int) (model AccountModel, ok bool)
GetAccount returns the account with given id if any, nil otherwise.
func (*DB) GetAccounts ¶
func (db *DB) GetAccounts() []AccountModel
GetAccounts returns all the accounts.
func (*DB) GetBottle ¶
func (db *DB) GetBottle(account, id int) (model BottleModel, ok bool)
GetBottle returns the bottle with the given id from the given account or nil if not found.
func (*DB) GetBottles ¶
func (db *DB) GetBottles(account int) ([]BottleModel, error)
GetBottles return the bottles from the given account.
func (*DB) GetBottlesByYears ¶
func (db *DB) GetBottlesByYears(account int, years []int) ([]BottleModel, error)
GetBottlesByYears returns the bottles with the vintage in the given array from the given account.
func (*DB) NewAccount ¶
func (db *DB) NewAccount() (model AccountModel)
NewAccount creates a new blank account resource.
func (*DB) NewBottle ¶
func (db *DB) NewBottle(account int) (model BottleModel, err error)
NewBottle creates a new bottle resource.
func (*DB) Reset ¶
func (db *DB) Reset()
Reset removes all entries from the database. Mainly intended for tests.
func (*DB) SaveAccount ¶
func (db *DB) SaveAccount(model AccountModel)
SaveAccount "persists" the account.
func (*DB) SaveBottle ¶
func (db *DB) SaveBottle(model BottleModel)
SaveBottle persists bottle to bottlesbase.