Documentation ¶
Index ¶
- type Article
- type Category
- type Tag
- type User
- func (u *User) Delete() error
- func (u *User) Insert() error
- func (u *User) Query() orm.QuerySeter
- func (u *User) Read(fields ...string) error
- func (u *User) ReadOrCreate(field string, fields ...string) (bool, int64, error)
- func (m *User) TableName() string
- func (u *User) Update(fields ...string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Article ¶
type Article struct { Id int // 文章ID Title string // 文章标题 Tags []*Tag `orm:"reverse(many)"` // 文章标签 多对多 一篇文章可能有多个标签,一个标签对应多篇文章 Category *Category `orm:"rel(fk)"` // 文章分类,一对多 Content string `orm:"size(10000)"` // 文章内容 Status bool // 状态 草稿/发布 CreateAt time.Time `orm:"auto_now_add;type(datetime)"` // 创建时间 }
func (*Article) Query ¶
func (a *Article) Query() orm.QuerySeter
type Category ¶
type Category struct { Id int CategoryName string `orm:"unique"` // 分类名称 Order int // 排序 Status bool // 启动或禁用 Article []*Article `orm:"reverse(many)"` // 分类下面的文章 CreateAt time.Time `orm:"auto_now_add;type(datetime)"` // 添加时间 }
Category 分类表
func (*Category) Query ¶
func (c *Category) Query() orm.QuerySeter
type Tag ¶
type Tag struct { Id int TagName string // 标签名称 Article []*Article `orm:"rel(m2m)"` // 对应的文章 CreateAt time.Time `orm:"auto_now_add;type(datetime)"` // 添加时间 }
Tag 标签
func (*Tag) Query ¶
func (t *Tag) Query() orm.QuerySeter
type User ¶
type User struct { Id int // 自增Id UserName string `orm:"unique;size(32)"` // 用户名 Password string `orm:"size(32)"` // 密码 Email string `orm:"size(50)"` // Email LastLogin time.Time `orm:"auto_now;type(datetime)"` // 上次登录时间 LoginCount int // 登录次数 LastIp string `orm:"size(32)"` // 上次登录IP Active int8 // 激活状态 }
User 用户表结构体
func (*User) Query ¶
func (u *User) Query() orm.QuerySeter
func (*User) ReadOrCreate ¶
Click to show internal directories.
Click to hide internal directories.