Documentation ¶
Index ¶
- type Cache
- type DeleteData
- type Post
- func (post *Post) AllowsReplies() bool
- func (post *Post) BeforeCreate(scope *gorm.Scope) error
- func (post *Post) IsAParentThread() bool
- func (post *Post) MakeRelationWith(reply *Post)
- func (post *Post) RepliesToAnotherPost() bool
- func (post *Post) Sages() bool
- func (post *Post) TableName() string
- func (post *Post) Validate() error
- type UpdateData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { Status int `json:"status"` Data interface{} `json:"data"` }
Cache is a struct used for caching posts, threads, index or errors.
type DeleteData ¶
DeleteData is a struct used for incoming DELETE requests or successful POST requests.
func (*DeleteData) Validate ¶
func (data *DeleteData) Validate() error
Validate checks if all fields are valid.
type Post ¶
type Post struct { ID uint64 `json:"id" gorm:"primary_key;AUTO_INCREMENT"` Content string `json:"content" gorm:"not null;size:1000"` Password string `json:"password,omitempty" gorm:"not null;size:128"` Pic *string `json:"pic,omitempty" gorm:"size:512"` ParentThread *uint64 `json:"parent_thread,omitempty"` ReplyTo *uint64 `json:"reply_to,omitempty"` CreatedAt *time.Time `json:"created_at" gorm:"not null;default:CURRENT_TIMESTAMP"` UpdatedAt *time.Time `json:"updated_at,omitempty" gorm:"not null;default:CURRENT_TIMESTAMP"` Sticky bool `json:"sticky,omitempty"` Closed bool `json:"closed,omitempty"` Sage bool `json:"sage,omitempty" gorm:"-"` // This field is not stored }
Post is the main struct. It defines how posts will be stored and represented.
func (*Post) AllowsReplies ¶
AllowsReplies checks if this post allows being replied.
func (*Post) BeforeCreate ¶
BeforeCreate makes the delete code if it's empty.
func (*Post) IsAParentThread ¶
IsAParentThread checks if this post starts a parent thread.
func (*Post) MakeRelationWith ¶
MakeRelationWith adds the parent thread ID to the post based on the reply.
func (*Post) RepliesToAnotherPost ¶
RepliesToAnotherPost checks if this post replies to another post.
type UpdateData ¶
type UpdateData struct { ID uint64 `json:"id"` Password string `json:"password"` Sticky bool `json:"sticky"` Closed bool `json:"closed"` }
UpdateData is a struct used for incoming PUT requests.
func (*UpdateData) Validate ¶
func (data *UpdateData) Validate() error
Validate checks if all fields are valid.