postgres

package
v0.0.0-...-0f708e2 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPInventory

func NewPInventory(config Config) db.Inventory

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

func (inventory *PInventoryDB) GetInventory(ctx context.Context) (error, []data.Stock)

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

Jump to

Keyboard shortcuts

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