Documentation
¶
Overview ¶
Package boilingcore has types and methods useful for generating code that acts as a fully dynamic ORM might.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FillAliases ¶
FillAliases takes the table information from the driver and fills in aliases where the user has provided none.
This leaves us with a complete list of Go names for all tables, columns, and relationships.
Types ¶
type Aliases ¶
type Aliases struct {
Tables map[string]TableAlias `toml:"tables,omitempty" json:"tables,omitempty"`
}
Aliases defines aliases for the generation run
func ConvertAliases ¶
func ConvertAliases(i interface{}) (a Aliases)
ConvertAliases is necessary because viper
It also supports two different syntaxes, because of viper:
[aliases.tables.table_name] fields... = "values" [aliases.tables.columns] colname = "alias" [aliases.tables.relationships.fkey_name] local = "x" foreign = "y"
Or alternatively (when toml key names or viper's lowercasing of key names gets in the way):
[[aliases.tables]] name = "table_name" fields... = "values" [[aliases.tables.columns]] name = "colname" alias = "alias" [[aliases.tables.relationships]] name = "fkey_name" local = "x" foreign = "y"
func (Aliases) ManyRelationship ¶
func (a Aliases) ManyRelationship(table, fkey, joinTable, joinTableFKey string) RelationshipAlias
ManyRelationship looks up a relationship alias, panics if not found. It will first try to look up a join table relationship, then it will try a normal one-to-many relationship. That's to say joinTable/joinTableFKey are used if they're not empty.
This allows us to skip additional conditionals in the templates.
func (Aliases) Table ¶
func (a Aliases) Table(table string) TableAlias
Table gets a table alias, panics if not found.