Documentation
¶
Overview ¶
Package model 管理数据模型
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct { Name string // 数据库的字段名 Len1 int // 长度1,仅对部分类型启作用 Len2 int // 长度2,仅对部分类型启作用 Nullable bool // 是否可以为 NULL GoType reflect.Type // Go 语言中的数据类型 GoName string // 结构字段名 HasDefault bool Default string // 默认值 // contains filtered or unexported fields }
Column 列结构
type ForeignKey ¶
type ForeignKey struct { Col *Column RefTableName, RefColName string UpdateRule, DeleteRule string }
ForeignKey 外键
type Metaer ¶
type Metaer interface {
Meta() string
}
Metaer 用于指定一个表级别的元数据。如表名,存储引擎等:
"name(tbl_name);engine(myISAM);charset(utf8)"
type Model ¶
type Model struct { Name string // 表的名称 Cols []*Column // 所有的列 KeyIndexes map[string][]*Column // 索引列 UniqueIndexes map[string][]*Column // 唯一索引列 FK map[string]*ForeignKey // 外键 PK []*Column // 主键 AI *Column // 自增列 OCC *Column // 乐观锁 Check map[string]string // Check 键名为约束名,键值为约束表达式 Meta map[string][]string // 表级别的数据,如存储引擎,表名和字符集等。 Constraints map[string]ConType // 约束名缓存 }
Model 表示一个数据库的表模型。数据结构从字段和字段的 struct tag 中分析得出。
Click to show internal directories.
Click to hide internal directories.