first commit
This commit is contained in:
30
internal/models/post_comment.go
Normal file
30
internal/models/post_comment.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// PostComment represents a comment on a post.
|
||||
type PostComment struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
UserID uuid.UUID `gorm:"not null" json:"user_id"`
|
||||
User User `gorm:"foreignKey:UserID" json:"user"`
|
||||
PostID uuid.UUID `gorm:"not null" json:"post_id"`
|
||||
Post Post `gorm:"foreignKey:PostID" json:"post"`
|
||||
Title string `gorm:"type:varchar(254);not null" json:"title"`
|
||||
Body string `gorm:"type:text;not null" json:"body"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
Slug string `gorm:"type:varchar(250);uniqueIndex:idx_post_comment_slug_parent;not null" json:"slug"`
|
||||
ParentID *uuid.UUID `gorm:"uniqueIndex:idx_post_comment_slug_parent" json:"parent_id,omitempty"`
|
||||
Parent *PostComment `gorm:"foreignKey:ParentID" json:"parent,omitempty"`
|
||||
Children []PostComment `gorm:"foreignKey:ParentID" json:"children,omitempty"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by PostComment.
|
||||
func (PostComment) TableName() string {
|
||||
return "post_comments"
|
||||
}
|
||||
Reference in New Issue
Block a user