Files
ng-blog/internal/model/blog.go
schreifuchs 893c49ec88
All checks were successful
Release / publish (push) Successful in 2m41s
feat: private posts
2025-10-17 23:59:34 +02:00

27 lines
689 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"`
Private bool `json:"private" gorm:"-"`
Secret *string `json:"secret,omitempty" gorm:"->;<-:create;unique"`
}
// 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"`
}