Documentation
¶
Index ¶
Constants ¶
View Source
const ( TagSmallCamelCase = "smallCamelCase" TagCamelCase = "camelCase" TagSnakeCase = "snakeCase" TagKebab = "kebab" )
Variables ¶
This section is empty.
Functions ¶
func InitFlagSetForConfig ¶ added in v0.4.0
Types ¶
type Column ¶
type Column struct {
Name string // column name
OrdinalPosition int // column ordinal position
ColumnGoType string // column data go type(string,int...)
ColumnType string // column type(varchar(256)...)
IsNullable bool // column is null or not
IsAutoIncrement bool // column auto increment or not
Default *string // default value
Comment string // column comment
Index []Index // index list
ForeignKeys []ForeignKey // Foreign key list
}
Column column information
type ColumnKeyType ¶
type ColumnKeyType int
ColumnKeyType column key type
const ( ColumnKeyNone ColumnKeyType = iota // default ColumnKeyTypePrimary // primary key ColumnKeyTypeNormalIndex // normal index key ColumnKeyTypeUniqueKey // unique key ColumnKeyTypeUnique // unique )
type ColumnSlice ¶
type ColumnSlice []*Column
func (ColumnSlice) Len ¶
func (t ColumnSlice) Len() int
func (ColumnSlice) Less ¶
func (t ColumnSlice) Less(i, j int) bool
func (ColumnSlice) Swap ¶
func (t ColumnSlice) Swap(i, j int)
type Config ¶
type Config struct {
DbTag string `yaml:"dbTag" json:"dbTag"` // db标签,默认gorm
Tags map[string]string `yaml:"tags" json:"tags"` // tags标签列表, support smallCamelCase, camelCase, snakeCase, kebab
EnableLint bool `yaml:"enableLint" json:"enableLint"` // 使能lint,例id->ID
EnableInt bool `yaml:"enableInt" json:"enableInt"` // 使能int8,uint8,int16,uint16,int32,uint32输出为int,uint
EnableIntegerInt bool `yaml:"enableIntegerInt" json:"enableIntegerInt"` // 使能int32,uint32输出为int,uint
EnableBoolInt bool `yaml:"enableBoolInt" json:"enableBoolInt"` // 使能bool输出int
DisableNullToPoint bool `yaml:"isNullToPoint" json:"isNullToPoint"` // 禁用字段为null时输出指针类型,将输出为sql.Nullxx
DisableCommentTag bool `yaml:"disableCommentTag" json:"disableCommentTag"` // 禁用注释放入tag标签中
EnableForeignKey bool `yaml:"enableForeignKey" json:"enableForeignKey"` // 输出外键
}
type DBModel ¶
type DBModel interface {
GetDatabase() (*Database, error)
GetTableAttributes() ([]TableAttribute, error)
GetTables(tb TableAttribute) (*Table, error)
GetCreateTableSQL(tbName string) (string, error)
}
DBModel Implement the interface to acquire database information.
type Database ¶
type Database struct {
Name string // database name, 数据库名
Tables []*Table // table information, 表信息
}
Database database information
type ForeignKey ¶
type ForeignKey struct {
TableName string // Affected tables .
ColumnName string // Which column of the affected table
}
ForeignKey Foreign key
type Index ¶
type Index struct {
KeyType ColumnKeyType // key type
KeyName string // index key name, 索引名称
IsMulti bool // Multiple key, 是否为复合索引
SeqInIndex int // union index sequence in index, 复合索引中的序列
IndexType string // index type, 索引类型(比如: BTREE, HASH, FULLTEXT)
}
Index database index/unique_index list
type Table ¶
type Table struct {
TableAttribute
Columns []*Column // column information
}
Table database table information
type TableAttribute ¶
type TableAttribute struct {
Name string // table name, 表名
Comment string // table comment, 表注释
CreateTableSQL string // Create SQL statements, 创建表的sql语句
}
TableAttribute database table name, comment and create table sql
type TableSlice ¶
type TableSlice []*Table
func (TableSlice) Len ¶
func (t TableSlice) Len() int
func (TableSlice) Less ¶
func (t TableSlice) Less(i, j int) bool
func (TableSlice) Swap ¶
func (t TableSlice) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.