Documentation
¶
Index ¶
Constants ¶
View Source
const ( WebTagSmallCamelCase = "smallCamelCase" WebTagCamelCase = "camelCase" WebTagSnakeCase = "snakeCase" WebTagKebab = "kebab" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct {
Name string // column name
OrdinalPosition int // column ordinal position
DataType string // column data 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 )
type Config ¶
type Config struct {
DbTag string `yaml:"dbTag" json:"dbTag"` // db标签, 默认gorm
WebTags []WebTag `yaml:"webTags" json:"webTags"` // web tags 标签列表
EnableLint bool `yaml:"enableLint" json:"enableLint"` // 使能lint, id -> ID
DisableNull bool `yaml:"disableNull" json:"disableNull"` // 不输出字段为null指针或sql.Nullxxx类型
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
IsNullToPoint bool `yaml:"isNullToPoint" json:"isNullToPoint"` // 是否字段为null时输出指针类型
IsOutSQL bool `yaml:"isOutSQL" json:"isOutSQL"` // 是否输出创建表的SQL
IsOutColumnName bool `yaml:"isOutColumnName" json:"isOutColumnName"` // 是否输出表的列名, 默认不输出
IsForeignKey bool `yaml:"isForeignKey" json:"isForeignKey"` // 输出外键
IsCommentTag bool `yaml:"isCommentTag" json:"isCommentTag"` // 注释同时放入tag标签中
}
type DBModel ¶
type DBModel interface {
GetDatabase(dbName string, tbNames ...string) (*Database, error)
GetTables(dbName string, tbNames ...string) ([]TableAttribute, error)
GetTableColumns(dbName string, 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
Click to show internal directories.
Click to hide internal directories.