19 lines
419 B
Go
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
|
||
|
|
}
|