Files
go_blog/models/article.go
2025-04-01 17:59:10 +08:00

19 lines
419 B
Go

package models
import "gorm.io/gorm"
type Article struct {
gorm.Model
Title string
Content string `gorm:"type:text"`
AuthorID uint
Tags []Tag `gorm:"many2many:article_tags;"`
}
// Tag represents the tag model
type Tag struct {
gorm.Model
Name string `gorm:"uniqueIndex"` // Ensures tag names are unique
Articles []Article `gorm:"many2many:article_tags;"` // Reverse relationship
}