chore: tags use array

This commit is contained in:
deepzz0
2021-04-28 12:50:06 +08:00
parent 9f563f0ae9
commit beea4f1746
6 changed files with 25 additions and 23 deletions

View File

@@ -1,21 +1,25 @@
// Package model provides ...
package model
import "time"
import (
"time"
"github.com/lib/pq"
)
// use snake_case as column name
// Article 文章
type Article struct {
ID int `gorm:"column:id;primaryKey" bson:"id"` // 自增ID
Author string `gorm:"column:author;not null" bson:"author"` // 作者名
Slug string `gorm:"column:slug;not null;uniqueIndex" bson:"slug"` // 文章缩略名
Title string `gorm:"column:title;not null" bson:"title"` // 标题
Count int `gorm:"column:count;not null" bson:"count"` // 评论数量
Content string `gorm:"column:content;not null" bson:"content"` // markdown内容
SerieID int `gorm:"column:serie_id;not null" bson:"serie_id"` // 专题ID
Tags string `gorm:"column:tags;not null" bson:"tags"` // tag,以逗号隔开
IsDraft bool `gorm:"column:is_draft;not null" bson:"is_draft"` // 是否是草稿
ID int `gorm:"column:id;primaryKey" bson:"id"` // 自增ID
Author string `gorm:"column:author;not null" bson:"author"` // 作者名
Slug string `gorm:"column:slug;not null;uniqueIndex" bson:"slug"` // 文章缩略名
Title string `gorm:"column:title;not null" bson:"title"` // 标题
Count int `gorm:"column:count;not null" bson:"count"` // 评论数量
Content string `gorm:"column:content;not null" bson:"content"` // markdown内容
SerieID int `gorm:"column:serie_id;not null" bson:"serie_id"` // 专题ID
Tags pq.StringArray `gorm:"column:tags;type:text[];not null" bson:"tags"` // tags
IsDraft bool `gorm:"column:is_draft;not null" bson:"is_draft"` // 是否是草稿
DeletedAt time.Time `gorm:"column:deleted_at;default:null" bson:"deleted_at"` // 删除时间
UpdatedAt time.Time `gorm:"column:updated_at;default:now()" bson:"updated_at"` // 更新时间