Documentation
¶
Index ¶
- func AddComptype(name string, rules TypeGroup) error
- func ComptypeContainsATypeKey(typeKey string) bool
- func ComptypeExists(target string) bool
- func GetComptypeNames() []string
- func GetMatchedPartsFromArgs(ct TypeGroup, arg string, matchedFields []interface{}) (string, []interface{})
- func LoadComptypes() error
- type Comptype
- type ComptypeCategory
- type Conversion
- type Data
- type GroupRuleKey
- type PropsEnum
- type PropsParse
- type PropsUnit
- type TypeGroup
- type TypeOp
- type TypeRule
- type UnitConversion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddComptype ¶
Add a user defined `TypeLabel` in `data`
func ComptypeExists ¶
func GetComptypeNames ¶
func GetComptypeNames() []string
func GetMatchedPartsFromArgs ¶
func GetMatchedPartsFromArgs(ct TypeGroup, arg string, matchedFields []interface{}) (string, []interface{})
GetFieldNamesFromArg will return the columns that match the provided arg, or nil on failure
func LoadComptypes ¶
func LoadComptypes() error
Types ¶
type ComptypeCategory ¶
type ComptypeCategory int
ComptypeCategory is an enum used by `ComptypeRule`
const ( Alias ComptypeCategory = iota Parse Enum Unit )
type Conversion ¶
type GroupRuleKey ¶
type GroupRuleKey struct {
Group *TypeGroup `json:"group"`
Rule *TypeRule `json:"rule"`
TypeKey *string `json:"typeKey"`
}
NOTE: This is only valid if TWO are nil
type PropsParse ¶
type PropsParse struct {
FuncKey string `json:"funcKey"`
OutType string `json:"outType"`
Conversion *Conversion `json:"conversion"`
}
type PropsUnit ¶
type PropsUnit struct {
BaseUnit string `json:"baseUnit"`
OtherUnits map[string]UnitConversion `json:"otherUnits"`
}
type TypeGroup ¶
type TypeGroup struct {
Op TypeOp `json:"op"`
GroupsRulesKeys []GroupRuleKey `json:"groupsRulesKeys"`
}
func GetComptypeRules ¶
type TypeRule ¶
type TypeRule struct {
Name string `json:"name"`
Rx string `json:"regex"`
Category ComptypeCategory `json:"category"`
PropsParse *PropsParse `json:"propsParse"`
PropsEnum *PropsEnum `json:"propsEnum"`
PropsUnit *PropsUnit `json:"propsUnit"`
}
ComptypeRule lets user specify rules to evaluate high level "types", a single user argument can have multiple rules, which are evaluated left to right, each rule corresponds to a column in a table. Rules include a regex to match the type on and a category that dictates how to evaluate the type. Categories include:
- Alias: simply identifies the matched string with an alias name
- Parse: for conversion of the matched string to another type, either directly or through a function (using a function key). A value that's parsed to a numeric type (float64 or int64) can also have a `UnitConversion` defined for it (e.g. g -> lbs)
- Enum: are treated as strings by go, but are stored as enum types in the db and identified as enums by the frontend JS
type UnitConversion ¶
Click to show internal directories.
Click to hide internal directories.