Documentation ¶
Overview ¶
db defines correct database query to send to external server connection string is grep via YAML file
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotConnected should be thrown when there isn't connection established to db ErrNotConnected error = errors.New("Invalid connection to db") // PingTimeout defines how long before connection should be ping for healthcheck PingTimeout time.Duration = 3 * time.Second // RetryTimeout defines how long to wait before retry to connect RetryTimeout time.Duration = 10 * time.Second )
View Source
var ErrExists error = errors.New("Table already exists")
ErrExists is thrown when table is already exists in schema
Functions ¶
func FetchQueries ¶
FetchQueries returns queries in given sql file
func GetProductID ¶
GetProductID returns context of whether a product exists in database or not
Types ¶
type Attribute ¶
type Attribute struct { ID int `json:"id"` Name string `json:"name"` IsProduct sql.NullBool `json:"isproduct"` IsMaterial sql.NullBool `json:"ismaterial"` IsSewingTrims sql.NullBool `json:"issewingtrims"` IsPackingTrims sql.NullBool `json:"ispackingtrims"` }
Attribute defines attribute structure from db
func FetchAttributes ¶
FetchAttributes returns list of attributes from database
type ConnectionPool ¶
type ConnectionPool struct { Host string `yaml:"host"` Port int `yaml:"port"` User string `yaml:"user"` Password string `yaml:"password"` Database string `yaml:"database"` SearchPath string `yaml:"search_path"` }
ConnectionPool defines info for connection string
func GetCreds ¶
func GetCreds(file string) (*ConnectionPool, error)
GetCreds returns credentials from secrets file
func() { conpool, err := GetCreds(fpath) if err != nil { log.Errorf(err) } cnnstr := fmt.Sprintf("host=%s user=%s password=%s port=%d database=%s search_path=%s", conpool.Host, conpool.User, conpool.Password, conpool.Port, conpool.Database, conpool.SearchPath) // Output: cnnstr:= [host=localhost user=postgres password=postgre database=postgres search_path=public] }()
type ProductInfo ¶
type ProductInfo struct { ProductID int `json:"product_id" example:"152"` ProductName string `json:"product_name"` AttributeValueID int `json:"attribute_value_id"` AttributeValueName sql.NullString `json:"attribute_value_name"` AttributeID int `json:"attribute_id"` AttributeName string `json:"attribute_name"` }
ProductInfo defines product info for each product
func FetchProducts ¶
func FetchProducts(query string) ([]ProductInfo, error)
FetchProducts returns product_info table for inference
type Registered ¶
type Registered struct {
RegClass string `json:"regclass"`
}
Registered defines validity of a table in db
Click to show internal directories.
Click to hide internal directories.