Documentation
¶
Index ¶
- type Connection
- type MockConnection
- func (c *MockConnection) AuthUser(username string, password string) (model.User, error)
- func (c *MockConnection) CreateCoffee(coffee model.Coffee) (model.Coffee, error)
- func (c *MockConnection) CreateOrder(userID int, orderItems []model.OrderItems) (model.Order, error)
- func (c *MockConnection) CreateToken(userID int) (model.Token, error)
- func (c *MockConnection) CreateUser(username string, password string) (model.User, error)
- func (c *MockConnection) DeleteOrder(userID int, orderID int) error
- func (c *MockConnection) DeleteToken(tokenID int, userID int) error
- func (c *MockConnection) GetCoffees(*int) (model.Coffees, error)
- func (c *MockConnection) GetIngredientsForCoffee(coffeeid int) (model.Ingredients, error)
- func (c *MockConnection) GetOrders(userID int, orderID *int) (model.Orders, error)
- func (c *MockConnection) GetToken(tokenID int, userID int) (model.Token, error)
- func (c *MockConnection) IsConnected() (bool, error)
- func (c *MockConnection) UpdateOrder(userID int, orderID int, orderItems []model.OrderItems) (model.Order, error)
- func (c *MockConnection) UpsertCoffeeIngredient(coffee model.Coffee, ingredient model.Ingredient) (model.CoffeeIngredient, error)
- type PostgresSQL
- func (c *PostgresSQL) AuthUser(username string, password string) (model.User, error)
- func (c *PostgresSQL) CreateCoffee(coffee model.Coffee) (model.Coffee, error)
- func (c *PostgresSQL) CreateOrder(userID int, orderItems []model.OrderItems) (model.Order, error)
- func (c *PostgresSQL) CreateToken(userID int) (model.Token, error)
- func (c *PostgresSQL) CreateUser(username string, password string) (model.User, error)
- func (c *PostgresSQL) DeleteOrder(userID int, orderID int) error
- func (c *PostgresSQL) DeleteToken(tokenID int, userID int) error
- func (c *PostgresSQL) GetCoffees(coffeeid *int) (model.Coffees, error)
- func (c *PostgresSQL) GetIngredientsForCoffee(coffeeid int) (model.Ingredients, error)
- func (c *PostgresSQL) GetOrders(userID int, orderID *int) (model.Orders, error)
- func (c *PostgresSQL) GetToken(tokenID int, userID int) (model.Token, error)
- func (c *PostgresSQL) IsConnected() (bool, error)
- func (c *PostgresSQL) UpdateOrder(userID int, orderID int, orderItems []model.OrderItems) (model.Order, error)
- func (c *PostgresSQL) UpsertCoffeeIngredient(coffee model.Coffee, ingredient model.Ingredient) (model.CoffeeIngredient, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection interface { IsConnected() (bool, error) GetCoffees(*int) (model.Coffees, error) GetIngredientsForCoffee(int) (model.Ingredients, error) CreateUser(string, string) (model.User, error) AuthUser(string, string) (model.User, error) CreateToken(int) (model.Token, error) GetToken(int, int) (model.Token, error) DeleteToken(int, int) error GetOrders(int, *int) (model.Orders, error) CreateOrder(int, []model.OrderItems) (model.Order, error) UpdateOrder(int, int, []model.OrderItems) (model.Order, error) DeleteOrder(int, int) error CreateCoffee(model.Coffee) (model.Coffee, error) UpsertCoffeeIngredient(model.Coffee, model.Ingredient) (model.CoffeeIngredient, error) }
func New ¶
func New(connection string) (Connection, error)
New creates a new connection to the database
type MockConnection ¶
func (*MockConnection) CreateCoffee ¶ added in v0.0.14
CreateCoffee creates a new coffee type
func (*MockConnection) CreateOrder ¶ added in v0.0.12
func (c *MockConnection) CreateOrder(userID int, orderItems []model.OrderItems) (model.Order, error)
CreateOrder -
func (*MockConnection) CreateToken ¶ added in v0.0.17
func (c *MockConnection) CreateToken(userID int) (model.Token, error)
CreateToken -
func (*MockConnection) CreateUser ¶ added in v0.0.12
CreateUser -
func (*MockConnection) DeleteOrder ¶ added in v0.0.12
func (c *MockConnection) DeleteOrder(userID int, orderID int) error
DeleteOrder -
func (*MockConnection) DeleteToken ¶ added in v0.0.17
func (c *MockConnection) DeleteToken(tokenID int, userID int) error
DeleteToken -
func (*MockConnection) GetCoffees ¶ added in v0.0.20
func (c *MockConnection) GetCoffees(*int) (model.Coffees, error)
GetCoffees -
func (*MockConnection) GetIngredientsForCoffee ¶ added in v0.0.9
func (c *MockConnection) GetIngredientsForCoffee(coffeeid int) (model.Ingredients, error)
GetIngredientsForCoffee -
func (*MockConnection) IsConnected ¶
func (c *MockConnection) IsConnected() (bool, error)
IsConnected -
func (*MockConnection) UpdateOrder ¶ added in v0.0.12
func (c *MockConnection) UpdateOrder(userID int, orderID int, orderItems []model.OrderItems) (model.Order, error)
UpdateOrder -
func (*MockConnection) UpsertCoffeeIngredient ¶ added in v0.0.14
func (c *MockConnection) UpsertCoffeeIngredient(coffee model.Coffee, ingredient model.Ingredient) (model.CoffeeIngredient, error)
UpsertCoffeeIngredient upserts a new coffee ingredient type
type PostgresSQL ¶
type PostgresSQL struct {
// contains filtered or unexported fields
}
func (*PostgresSQL) AuthUser ¶ added in v0.0.12
AuthUser checks whether username and password matches
func (*PostgresSQL) CreateCoffee ¶ added in v0.0.14
CreateCoffee creates a new coffee
func (*PostgresSQL) CreateOrder ¶ added in v0.0.12
func (c *PostgresSQL) CreateOrder(userID int, orderItems []model.OrderItems) (model.Order, error)
CreateOrder creates a new order in the database
func (*PostgresSQL) CreateToken ¶ added in v0.0.17
func (c *PostgresSQL) CreateToken(userID int) (model.Token, error)
CreateToken creates a new token
func (*PostgresSQL) CreateUser ¶ added in v0.0.12
CreateUser creates a new user
func (*PostgresSQL) DeleteOrder ¶ added in v0.0.12
func (c *PostgresSQL) DeleteOrder(userID int, orderID int) error
DeleteOrder deletes an existing order in the database
func (*PostgresSQL) DeleteToken ¶ added in v0.0.17
func (c *PostgresSQL) DeleteToken(tokenID int, userID int) error
DeleteToken deletes an existing token in the database
func (*PostgresSQL) GetCoffees ¶ added in v0.0.20
func (c *PostgresSQL) GetCoffees(coffeeid *int) (model.Coffees, error)
GetCoffees returns all coffees from the database
func (*PostgresSQL) GetIngredientsForCoffee ¶ added in v0.0.8
func (c *PostgresSQL) GetIngredientsForCoffee(coffeeid int) (model.Ingredients, error)
GetIngredientsForCoffee get the ingredients for the given coffeeid
func (*PostgresSQL) IsConnected ¶
func (c *PostgresSQL) IsConnected() (bool, error)
IsConnected checks the connection to the database and returns an error if not connected
func (*PostgresSQL) UpdateOrder ¶ added in v0.0.12
func (c *PostgresSQL) UpdateOrder(userID int, orderID int, orderItems []model.OrderItems) (model.Order, error)
UpdateOrder updates an existing order in the database
func (*PostgresSQL) UpsertCoffeeIngredient ¶ added in v0.0.14
func (c *PostgresSQL) UpsertCoffeeIngredient(coffee model.Coffee, ingredient model.Ingredient) (model.CoffeeIngredient, error)
UpsertCoffeeIngredient upserts a new coffee ingredient