config

package
v1.0.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SnakeCase  naming = "snake_case"
	CamelCase  naming = "camelCase"
	PascalCase naming = "PascalCase"
)
View Source
const (
	DefaultConfigFile    = "sqlgen.yml"
	DefaultGeneratedFile = "generated.go"
	DefaultStructTag     = "sql"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Source           []string  `yaml:"src"`
	Driver           SqlDriver `yaml:"driver"`
	NamingConvention naming    `yaml:"naming_convention,omitempty"`
	Tag              string    `yaml:"struct_tag,omitempty"`
	// Whether to quote the table name and column name
	OmitQuoteIdentifier bool              `yaml:"omit_quote_identifier,omitempty"`
	OmitGetters         bool              `yaml:"omit_getters,omitempty"`
	Strict              *bool             `yaml:"strict,omitempty"`
	Exec                ExecConfig        `yaml:"exec"`
	Getter              GetterConfig      `yaml:"getter"`
	Migration           *MigrationConfig  `yaml:"migration"`
	Database            *DatabaseConfig   `yaml:"database"`
	SourceMap           bool              `yaml:"source_map"`
	SkipHeader          bool              `yaml:"skip_header"`
	SkipModTidy         bool              `yaml:"skip_mod_tidy"`
	Models              map[string]*Model `yaml:"models"`
}

func DefaultConfig

func DefaultConfig() *Config

func LoadConfigFrom

func LoadConfigFrom(src string) (*Config, error)

func (*Config) Merge

func (c *Config) Merge(mapCfg *Config) *Config

func (Config) RenameFunc

func (c Config) RenameFunc() func(string) string

type DatabaseConfig

type DatabaseConfig struct {
	Package  string                  `yaml:"package"`
	Dir      string                  `yaml:"dir"`
	Filename string                  `yaml:"filename"`
	Operator *DatabaseOperatorConfig `yaml:"operator"`
}

type DatabaseOperatorConfig

type DatabaseOperatorConfig struct {
	Package  string `yaml:"package"`
	Dir      string `yaml:"dir"`
	Filename string `yaml:"filename"`
}

type ExecConfig

type ExecConfig struct {
	// Skip `generated.go` file being generated if the input has no matching struct
	SkipEmpty bool `yaml:"skip_empty"`
	// Declare the name of generated go file. Default is `generated.go`
	Filename string `yaml:"filename"`
}

type GetterConfig

type GetterConfig struct {
	Prefix string `yaml:"prefix"`
}

type MigrationConfig

type MigrationConfig struct {
}

type Model

type Model struct {
	DataType   string `yaml:"data_type"`
	Scanner    string `yaml:"scan" validate:"required_with=Valuer"`
	SQLScanner string `yaml:"sql_scan" validate:"required_with=SQLValuer"`
	Valuer     string `yaml:"value" validate:"required_with=Scanner"`
	SQLValuer  string `yaml:"sql_value" validate:"required_with=SQLScanner"`
}

type SqlDriver

type SqlDriver string
const (
	MySQL    SqlDriver = "mysql"
	Postgres SqlDriver = "postgres"
	Sqlite   SqlDriver = "sqlite"
)

Jump to

Keyboard shortcuts

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