data

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

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

type MockConnection struct {
	mock.Mock
}

func (*MockConnection) AuthUser added in v0.0.12

func (c *MockConnection) AuthUser(username string, password string) (model.User, error)

AuthUser -

func (*MockConnection) CreateCoffee added in v0.0.14

func (c *MockConnection) CreateCoffee(coffee model.Coffee) (model.Coffee, error)

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

func (c *MockConnection) CreateUser(username string, password string) (model.User, error)

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) GetOrders added in v0.0.12

func (c *MockConnection) GetOrders(userID int, orderID *int) (model.Orders, error)

GetOrders -

func (*MockConnection) GetToken added in v0.0.17

func (c *MockConnection) GetToken(tokenID int, userID int) (model.Token, error)

GetToken -

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

func (c *PostgresSQL) AuthUser(username string, password string) (model.User, error)

AuthUser checks whether username and password matches

func (*PostgresSQL) CreateCoffee added in v0.0.14

func (c *PostgresSQL) CreateCoffee(coffee model.Coffee) (model.Coffee, error)

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

func (c *PostgresSQL) CreateUser(username string, password string) (model.User, error)

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) GetOrders added in v0.0.12

func (c *PostgresSQL) GetOrders(userID int, orderID *int) (model.Orders, error)

GetOrders returns orders from the database

func (*PostgresSQL) GetToken added in v0.0.17

func (c *PostgresSQL) GetToken(tokenID int, userID int) (model.Token, error)

GetToken checks whether token exists

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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