Files
ng-blog/internal/model/blog.go
2025-05-05 10:00:50 +02:00

25 lines
571 B
Go

package model
import (
"gorm.io/gorm"
)
// Post represents a blog post with associated comments and user ID.
type Post struct {
gorm.Model
ID uint `gorm:"primarykey" json:"id"`
Title string `json:"title"`
TLDR string `json:"tldr"`
Content string `json:"content"`
Comments []Comment
UserID uint `gorm:"->;<-:create"`
}
// Comment represents a comment on a post, including its ID, post association, content, and creator.
type Comment struct {
ID uint
PostID uint
Content string `json:"content"`
UserID uint `gorm:"->;<-:create"`
}