diff --git a/models/article.go b/models/article.go index 15898ad..86f98da 100644 --- a/models/article.go +++ b/models/article.go @@ -2,9 +2,11 @@ package models type Article struct { Id string `gorm:"primaryKey" json:"id"` - Author User `json:"author"` + AuthorId string `gorm:"index" json:"author_id"` Title string `json:"title"` Sections []ArticleSection `gorm:"serializer:json" json:"sections"` + + Author User `gorm:"foreignKey:AuthorId" json:"author"` } type ArticleSection struct {