Documentation
¶
Index ¶
- Variables
- func ConvertRelationships(i interface{}) map[string][]orm.Relationship
- func FillAliases(a *Aliases, tables []drivers.Table)
- func ModelsPackage(relPath string) (string, error)
- type Aliases
- type Config
- type Importer
- type Inflections
- type Output
- type RelationshipAlias
- type Replace
- type State
- type TableAlias
Constants ¶
This section is empty.
Variables ¶
var (
ModelTemplates, _ = fs.Sub(templates, "templates/models")
FactoryTemplates, _ = fs.Sub(templates, "templates/factory")
)
Functions ¶
func ConvertRelationships ¶
func ConvertRelationships(i interface{}) map[string][]orm.Relationship
ConvertRelationships is necessary because viper
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.
func ModelsPackage ¶
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{}) 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) Table ¶
func (a Aliases) Table(table string) TableAlias
Table gets a table alias, panics if not found.
type Config ¶
type Config[T any] struct { Driver drivers.Interface[T] `toml:"driver,omitempty" json:"driver,omitempty"` Tags []string `toml:"tags,omitempty" json:"tags,omitempty"` NoTests bool `toml:"no_tests,omitempty" json:"no_tests,omitempty"` NoBackReferencing bool `toml:"no_back_reference,omitempty" json:"no_back_reference,omitempty"` Wipe bool `toml:"wipe,omitempty" json:"wipe,omitempty"` StructTagCasing string `toml:"struct_tag_casing,omitempty" json:"struct_tag_casing,omitempty"` RelationTag string `toml:"relation_tag,omitempty" json:"relation_tag,omitempty"` TagIgnore []string `toml:"tag_ignore,omitempty" json:"tag_ignore,omitempty"` Aliases Aliases `toml:"aliases,omitempty" json:"aliases,omitempty"` Replacements []Replace `toml:"replacements,omitempty" json:"replacements,omitempty"` Relationships map[string][]orm.Relationship `toml:"relationships,omitempty" json:"relationships,omitempty"` Inflections Inflections `toml:"inflections,omitempty" json:"inflections,omitempty"` Generator string `toml:"generator" json:"generator"` Outputs []*Output `toml:"package" json:"package"` CustomTemplateFuncs template.FuncMap `toml:"-" json:"-"` ModelsPackage string `toml:"models_package" json:"models_package"` }
Config for the running of the commands
type Importer ¶
type Importer map[string]struct{}
type Inflections ¶
type RelationshipAlias ¶
type RelationshipAlias struct { Local string `toml:"local,omitempty" json:"local,omitempty"` Foreign string `toml:"foreign,omitempty" json:"foreign,omitempty"` }
RelationshipAlias defines the naming for both sides of a foreign key.
type Replace ¶
type Replace struct { Tables []string `toml:"tables,omitempty" json:"tables,omitempty"` Match drivers.Column `toml:"match,omitempty" json:"match,omitempty"` Replace drivers.Column `toml:"replace,omitempty" json:"replace,omitempty"` }
Replace replaces a column type with something else
func ConvertReplacements ¶
func ConvertReplacements(i interface{}) []Replace
ConvertReplacements is necessary because viper
type State ¶
type State[T any] struct { Config *Config[T] Dialect string Schema string Tables []drivers.Table ExtraInfo T }
State holds the global data needed by most pieces to run
type TableAlias ¶
type TableAlias struct { UpPlural string `toml:"up_plural,omitempty" json:"up_plural,omitempty"` UpSingular string `toml:"up_singular,omitempty" json:"up_singular,omitempty"` DownPlural string `toml:"down_plural,omitempty" json:"down_plural,omitempty"` DownSingular string `toml:"down_singular,omitempty" json:"down_singular,omitempty"` Columns map[string]string `toml:"columns,omitempty" json:"columns,omitempty"` Relationships map[string]string `toml:"relationships,omitempty" json:"relationships,omitempty"` }
TableAlias defines the spellings for a table name in Go
func (TableAlias) Column ¶
func (t TableAlias) Column(column string) string
Column get's a column's aliased name, panics if not found.
func (TableAlias) Relationship ¶
func (t TableAlias) Relationship(fkey string) string
Relationship looks up a relationship, panics if not found.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package drivers talks to various database backends and retrieves table, column, type, and foreign key information
|
Package drivers talks to various database backends and retrieves table, column, type, and foreign key information |
Package importers helps with dynamic imports for templating
|
Package importers helps with dynamic imports for templating |