Documentation ¶
Overview ¶
Package model provides drink and inventory models for the backend of ABV.
Index ¶
- type Date
- type DateRange
- type Drink
- type DrinkEntry
- type Model
- func (m *Model) BarcodeExists(bc string) (bool, error)
- func (m *Model) ClearInputTable() error
- func (m *Model) ClearOutputTable() error
- func (m *Model) CreateDrink(d Drink) (int, error)
- func (m *Model) CreateTablesIfNeeded()
- func (m *Model) DeleteDrink(bc string) error
- func (m *Model) GetAllStoredDrinks() ([]Drink, error)
- func (m *Model) GetCountByBarcode(bc string) (int, error)
- func (m *Model) GetDrinkByBarcode(bc string) (Drink, error)
- func (m *Model) GetInputWithinDateRange(dates DateRange) (result []StockedDrink, err error)
- func (m *Model) GetInventory() ([]StockedDrink, error)
- func (m *Model) GetInventorySorted(sortFields []string) ([]StockedDrink, error)
- func (m *Model) GetInventoryTotalQuantity() (int, error)
- func (m *Model) GetInventoryTotalVariety() (int, error)
- func (m *Model) GetOutputWithinDateRange(dates DateRange) (result []StockedDrink, err error)
- func (m *Model) InputDrinks(d DrinkEntry) (int, error)
- func (m *Model) OutputDrinks(d DrinkEntry) (int, error)
- func (m *Model) UndoInputDrinks(id int) error
- func (m *Model) UndoOutputDrinks(id int) error
- type StockedDrink
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Drink ¶
type Drink struct { Barcode string Brand string Name string Abv float64 Ibu int Type string Shorttype string Logo string Date Date Country string }
Drink stores information about an available beverage
type DrinkEntry ¶
DrinkEntry defines quantities of drinks for transactions
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model controls all the data flow into and out of the db layer
func (*Model) BarcodeExists ¶
BarcodeExists checks if a barcode is already in the database
func (*Model) ClearInputTable ¶
ClearInputTable deletes all stocking records
func (*Model) ClearOutputTable ¶
ClearOutputTable deletes all serving records
func (*Model) CreateDrink ¶
CreateDrink adds an entry to the Drinks table, returning the id
func (*Model) CreateTablesIfNeeded ¶
func (m *Model) CreateTablesIfNeeded()
CreateTablesIfNeeded ensures that the db has the necessary tables
func (*Model) DeleteDrink ¶
DeleteDrink removes an entry from the Drinks table using its barcode
func (*Model) GetAllStoredDrinks ¶
GetAllStoredDrinks returns every saved Drink row in the database
func (*Model) GetCountByBarcode ¶
GetCountByBarcode returns the total number of currently stocked beers with a specific barcode
func (*Model) GetDrinkByBarcode ¶
GetDrinkByBarcode returns all stored information about a drink based on its barcode
func (*Model) GetInputWithinDateRange ¶
func (m *Model) GetInputWithinDateRange(dates DateRange) (result []StockedDrink, err error)
GetInputWithinDateRange returns every drink inputted within a date range, inclusive
func (*Model) GetInventory ¶
func (m *Model) GetInventory() ([]StockedDrink, error)
GetInventory returns every drink with at least one quantity in stock, sorted by Type
func (*Model) GetInventorySorted ¶
func (m *Model) GetInventorySorted(sortFields []string) ([]StockedDrink, error)
GetInventorySorted returns every drink with at least one quantity in stock, sorted by the provided Fields
func (*Model) GetInventoryTotalQuantity ¶
GetInventoryTotalQuantity returns the total number of beer bottles in stock
func (*Model) GetInventoryTotalVariety ¶
GetInventoryTotalVariety returns the total number of beer varieties in stock
func (*Model) GetOutputWithinDateRange ¶
func (m *Model) GetOutputWithinDateRange(dates DateRange) (result []StockedDrink, err error)
GetOutputWithinDateRange returns every drink served within a date range, inclusive
func (*Model) InputDrinks ¶
func (m *Model) InputDrinks(d DrinkEntry) (int, error)
InputDrinks adds an entry to the Input table, returning the id
func (*Model) OutputDrinks ¶
func (m *Model) OutputDrinks(d DrinkEntry) (int, error)
OutputDrinks adds an entry to the Output table, returning the id
func (*Model) UndoInputDrinks ¶
UndoInputDrinks removes an entry from the Input table by id
func (*Model) UndoOutputDrinks ¶
UndoOutputDrinks removes an entry from the Output table by id
type StockedDrink ¶
StockedDrink is an extension of drink with an additional field for quantity