This commit is contained in:
2025-12-10 05:23:18 +00:00
parent 3bb8e9c9d3
commit 3fa37fa10e

View File

@@ -6,6 +6,6 @@ type Post struct {
gorm.Model // includes ID, CreatedAt, UpdatedAt, DeletedAt
Title string `gorm:"not null" json:"title"`
AuthorID uint `json:"-"`
Author User `gorm:"foreignKey:AuthorID;references:ID" json:"author"`
Author User `gorm:"foreignKey:AuthorID,constraint:OnUpdate:CASCADE,OnDelete:SET NULL" json:"author"`
Content string `json:"content"`
}