Appearance
反射标签
常规标签
go
type Student struct {
ID int `gorm:"primary_key;AUTO_INCREMENT"` //primary_key 设置主键 AUTO_INCREMENT 自动增长
Name string `gorm:"not null"` //not nul 不为空
Age string `gorm:"index;comment:年龄"` //index 设置索引 index:name_index 可以设置索引名称为name_index
Phone string `gorm:"unique_index"` //unique_index 设置唯一索引
Email string `gorm:"unique"` //unique 设置唯一
Sex string `gorm:"column:gender"` //column 字段重新命名
Intro string `gorm:"size:200"` //size 设置长度
Desc string `gorm:"-"` //- 冗余字段
IsDel string `gorm:"default:0"` //default 设置默认值
IsHid string `gorm:"type:int"` //type 修改字段类型,不推荐使用
CreateAt time.Time `gorm:"comment:创建时间"` //comment 字段备注