Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct {
// 注意字段名一般为首字母大写;反引号+(主键pk,自增auto)
Id int `orm:"pk;auto"`
Aname string `orm:"size(20)"`
// auto_now 每次model保存时都会对时间自动更新
Atime time.Time `orm:"auto_now"`
Acount int `orm:"default(0);null"`
Acontent string // 文章内容
Aimg string // 文章存放路径
Atype *ArticleType `orm:"rel(fk)"` //设置一对多关系,一篇文章对应一个类型,文章类型为外键
User *User `orm:"rel(fk)"` //设置一对多的关系,一篇文章对应一个创建者
}
文章表
type ArticleType ¶
type ArticleType struct {
Id int
Typename string `orm:"size(20)"`
Articles []*Article `orm:"reverse(many)"` // 设置一对多的反向关系,一个类型可以包含多篇文章
}
文章类型表
Click to show internal directories.
Click to hide internal directories.