Documentation ¶
Index ¶
- func NewPInventory(config Config) db.Inventory
- type Config
- type PInventoryDB
- func (inventory *PInventoryDB) GetInventory(ctx context.Context) (error, []data.Stock)
- func (inventory *PInventoryDB) GetProductStock(ctx context.Context) (error, data.ProductStocks)
- func (inventory *PInventoryDB) Open() error
- func (inventory *PInventoryDB) Ping() error
- func (inventory *PInventoryDB) SellProduct(ctx context.Context, productName string) error
- func (inventory *PInventoryDB) UploadInventory(ctx context.Context, inventoryToInsert data.Inventory) (error, int)
- func (inventory *PInventoryDB) UploadProducts(ctx context.Context, product data.Products) (error, int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPInventory ¶
NewPInventory creates new Postgres inventory instance
Types ¶
type Config ¶
type Config struct { Logger *logrus.Entry Driver string Host string Port string User string Password string Dbname string }
Config keeps db related configurations
type PInventoryDB ¶
type PInventoryDB struct {
// contains filtered or unexported fields
}
PInventoryDB keep db and configuration
func (*PInventoryDB) GetInventory ¶
GetInventory gets all inventory/stock info in system
func (*PInventoryDB) GetProductStock ¶
func (inventory *PInventoryDB) GetProductStock(ctx context.Context) (error, data.ProductStocks)
GetProductStock gets the stock of the available products in system
func (*PInventoryDB) Open ¶
func (inventory *PInventoryDB) Open() error
Open opens a postgres database
func (*PInventoryDB) Ping ¶
func (inventory *PInventoryDB) Ping() error
Ping verifies a connection to the database is still alive
func (*PInventoryDB) SellProduct ¶
func (inventory *PInventoryDB) SellProduct(ctx context.Context, productName string) error
SellProduct checks if the product exist and in stock. If true then update inventory accordingly
func (*PInventoryDB) UploadInventory ¶
func (inventory *PInventoryDB) UploadInventory(ctx context.Context, inventoryToInsert data.Inventory) (error, int)
UploadInventory inserts the inventory info into db
func (*PInventoryDB) UploadProducts ¶
func (inventory *PInventoryDB) UploadProducts(ctx context.Context, product data.Products) (error, int)
UploadProducts inserts the product info into db
Click to show internal directories.
Click to hide internal directories.