db

package
v0.0.0-...-5008859 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateUp

func MigrateUp(dbURL string)

MigrateUp runs migrations

Types

type Db

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

Db is the database connection

func Connect

func Connect(dbURL string) *Db

Connect makes a postgres connection

func (*Db) CloseConnection

func (db *Db) CloseConnection()

CloseConnection closes the sql conection

func (*Db) CreatePrices

func (db *Db) CreatePrices(drinks *[]exel.Drink) (OK bool, error error)

CreatePrices creates new prices for juomas

func (*Db) DeleteDrinks

func (db *Db) DeleteDrinks() error

DeleteDrinks deletes all the drinks from the db

func (*Db) GetAllBeers

func (db *Db) GetAllBeers() (d []model.Drink, error error)

GetAllBeers gets all the beers from postgres

func (*Db) GetAllDrinks

func (db *Db) GetAllDrinks() ([]model.Drink, error)

GetAllDrinks finds all the drinks

func (*Db) GetAllPrices

func (db *Db) GetAllPrices() ([]model.Price, error)

GetAllPrices gets all the prices

func (*Db) GetDrinkByProdID

func (db *Db) GetDrinkByProdID(ProductID string) (d model.Drink, error error)

GetDrinkByProdID gets one juoma with specified productID

func (*Db) GetPriceHistory

func (db *Db) GetPriceHistory(productID string) ([]model.Price, error)

GetPriceHistory returns the price history of one drink

func (*Db) InsertDrinks

func (db *Db) InsertDrinks(drinks *[]exel.Drink) (OK bool, error error)

InsertDrinks reads the exel file and inserts to postgres

func (*Db) InsertManyDrinks

func (db *Db) InsertManyDrinks() (string, error)

InsertManyDrinks reads the alko file and inserts everything to postgres

func (*Db) SearchForBeer

func (db *Db) SearchForBeer(term string) (d []model.Drink, error error)

SearchForBeer gets one or more beer based on search results

func (*Db) SearchForDrink

func (db *Db) SearchForDrink(term string) (j []model.Drink, error error)

SearchForDrink gets one or more juoma based on search results

Jump to

Keyboard shortcuts

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