25 lines
571 B
Go
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"`
|
|
}
|