config

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_FILE_MODE = 0644
	DEFAULT_DIR_MODE  = 0755
)
View Source
const (
	INIT_FILE_NAME   = "init"
	SINGLE_FILE_NAME = "tables"
	QUERY_FILE_NAME  = "queries"

	XORM_TAG_NAME        = "xorm"
	XORM_TAG_NOT_NULL    = "notnull"
	XORM_TAG_AUTO_INCR   = "autoincr"
	XORM_TAG_PRIMARY_KEY = "pk"
	XORM_TAG_UNIQUE      = "unique"
	XORM_TAG_INDEX       = "index"
)

Variables

This section is empty.

Functions

func SaveSettings

func SaveSettings(file string) error

Types

type AppConfig

type AppConfig struct {
	Debug       bool `json:"debug" yaml:"debug"`
	PluralTable bool `json:"plural_table" yaml:"plural_table"`
}

type ConnConfig

type ConnConfig struct {
	DriverName string     `json:"driver_name" yaml:"driver_name"`
	ReadOnly   string     `json:"read_only" yaml:"read_only"`
	Partition  PartConfig `json:"partition" yaml:"partition"`
	Params     dialect.ConnParams
}

type DataSource

type DataSource struct {
	ConnKey   string
	Partition PartConfig
	Dialect   dialect.Dialect
	*ReverseSource
}

func NewDataSource

func NewDataSource(k string, c ConnConfig) *DataSource

type IConnectSettings added in v0.3.1

type IConnectSettings interface {
	GetConnection(key string) ConnConfig
}

type IReverseSettings added in v0.3.1

type IReverseSettings interface {
	GetReverseTargets() []ReverseTarget
	GetDataSources(names []string) []*DataSource
}

type PartConfig added in v0.3.1

type PartConfig struct {
	TablePrefix   string   `json:"table_prefix" yaml:"table_prefix"`
	IncludeTables []string `json:"include_tables" yaml:"include_tables"`
	ExcludeTables []string `json:"exclude_tables" yaml:"exclude_tables"`
}

type ReverseConfig

type ReverseConfig struct {
	Kind    string          `yaml:"kind"`
	Name    string          `yaml:"name"`
	Source  ReverseSource   `yaml:"source"`
	Targets []ReverseTarget `yaml:"targets"`
}

ReverseConfig represents a reverse configuration

type ReverseSource

type ReverseSource struct {
	Database string `yaml:"database"`
	ConnStr  string `yaml:"conn_str"`
}

ReverseSource represents a reverse source which should be a database connection

type ReverseTarget

type ReverseTarget struct {
	Type          string   `yaml:"type"`
	IncludeTables []string `yaml:"include_tables"`
	ExcludeTables []string `yaml:"exclude_tables"`
	TableMapper   string   `yaml:"table_mapper"`
	ColumnMapper  string   `yaml:"column_mapper"`
	TemplatePath  string   `yaml:"template_path"`
	Template      string   `yaml:"template"`
	MultipleFiles bool     `yaml:"multiple_files"`
	OutputDir     string   `yaml:"output_dir"`
	TablePrefix   string   `yaml:"table_prefix"`
	Language      string   `yaml:"language"`

	Funcs     map[string]string `yaml:"funcs"`
	Formatter string            `yaml:"formatter"`
	Importter string            `yaml:"importter"`
	ExtName   string            `yaml:"ext_name"`

	NameSpace       string `yaml:"name_space"`
	GenJsonTag      bool   `yaml:"gen_json_tag"`
	GenTableName    bool   `yaml:"gen_table_name"`
	GenQueryMethods bool   `yaml:"gen_query_methods"`
	ApplyMixins     bool   `yaml:"apply_mixins"`
}

ReverseTarget represents a reverse target

func (ReverseTarget) GetFileName

func (t ReverseTarget) GetFileName(name string) string

func (ReverseTarget) MergeOptions

func (t ReverseTarget) MergeOptions(name string, part PartConfig) ReverseTarget

type Settings

type Settings struct {
	Application    AppConfig             `json:"application" yaml:"application"`
	Connections    map[string]ConnConfig `json:"connections" yaml:"connections"`
	ReverseTargets []ReverseTarget       `json:"reverse_targets" yaml:"reverse_targets"`
	// contains filtered or unexported fields
}

func GetSettings

func GetSettings() *Settings

func ReadSettings

func ReadSettings(file string) (*Settings, error)

func (Settings) GetApplication added in v0.3.1

func (cfg Settings) GetApplication() AppConfig

func (Settings) GetConnection added in v0.3.1

func (cfg Settings) GetConnection(key string) ConnConfig

func (Settings) GetDataSources

func (cfg Settings) GetDataSources(names []string) (ds []*DataSource)

func (Settings) GetReverseTargets added in v0.3.1

func (cfg Settings) GetReverseTargets() []ReverseTarget

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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