posts

package
v0.2.74 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(entity *Entity) error

func CreateWithDB added in v0.2.61

func CreateWithDB(db *gorm.DB, entity *Entity) error

CreateWithDB leaves event publication to the transaction owner.

func DeleteEntity

func DeleteEntity(entity *Entity) int64

func GetMapByIds

func GetMapByIds(ids []uint64) map[uint64]*Entity

func GetMaxId

func GetMaxId() uint64

func GetMaxPostNoByTopicId

func GetMaxPostNoByTopicId(topicId uint64) uint64

func Save

func Save(entity *Entity) error

func SaveNoUpdate

func SaveNoUpdate(entity *Entity) error

func SaveOrCreateById

func SaveOrCreateById(entity *Entity) int64

func SaveReviewed added in v0.2.74

func SaveReviewed(entity *Entity, version uint64) error

SaveReviewed compares the version before changing content or an admin decision.

func UpdateProcessStatus

func UpdateProcessStatus(id uint64, processStatus int8) error

Types

type Entity

type Entity struct {
	PublishedAt       *time.Time     `gorm:"column:published_at" json:"-"`
	Id                uint64         `` /* 131-byte string literal not displayed */
	TopicId           uint64         `` /* 238-byte string literal not displayed */
	PostNo            uint64         `gorm:"column:post_no;type:bigint unsigned;not null;default:0;uniqueIndex:idx_posts_topic_no,priority:2;" json:"postNo"`
	UserId            uint64         `gorm:"column:user_id;type:bigint unsigned;not null;default:0;index;" json:"userId"`
	ReplyToPostId     uint64         `gorm:"column:reply_to_post_id;type:bigint unsigned;not null;default:0;" json:"replyToPostId"`
	Content           string         `gorm:"column:content;type:text;" json:"content"`
	RenderedHTML      string         `gorm:"column:rendered_html;type:text;" json:"renderedHTML"`
	RenderedVersion   uint32         `gorm:"column:rendered_version;type:bigint unsigned;not null;default:0;" json:"renderedVersion"`
	ProcessStatus     int8           `gorm:"column:process_status;type:tinyint;not null;default:0;index:idx_posts_topic_process,priority:2;" json:"processStatus"`
	ModerationStatus  string         `` /* 130-byte string literal not displayed */
	ModerationVersion uint64         `gorm:"column:moderation_version;type:bigint unsigned;not null;default:0" json:"-"`
	ModerationReason  string         `gorm:"column:moderation_reason;type:varchar(512);not null;default:''" json:"-"`
	ModeratedAt       *time.Time     `gorm:"column:moderated_at" json:"-"`
	CreatedAt         time.Time      `gorm:"column:created_at;autoCreateTime;<-:create;index:idx_posts_topic_created,priority:2;" json:"createdAt"`
	UpdatedAt         time.Time      `gorm:"column:updated_at;autoUpdateTime;;index:idx_posts_review,priority:2" json:"updatedAt"`
	DeletedAt         gorm.DeletedAt `json:"-"`
}

func Get

func Get(id uint64) (entity Entity)

func GetByIds

func GetByIds(ids []uint64) (entities []*Entity)

func GetByTopicIdAfter

func GetByTopicIdAfter(topicId uint64, id uint64, limit int) (entities []*Entity)

func GetByTopicIdBefore

func GetByTopicIdBefore(topicId uint64, id uint64, limit int) (entities []*Entity)

func GetByTopicPostNoAfter

func GetByTopicPostNoAfter(topicId uint64, postNo uint64, limit int) (entities []*Entity)

func GetByTopicPostNoAsc

func GetByTopicPostNoAsc(topicId uint64, limit int) (entities []*Entity)

func GetByTopicPostNoAtOrAfter

func GetByTopicPostNoAtOrAfter(topicId uint64, postNo uint64) (entity Entity, ok bool)

func GetByTopicPostNoAtOrBefore

func GetByTopicPostNoAtOrBefore(topicId uint64, postNo uint64) (entity Entity, ok bool)

func GetByTopicPostNoBefore

func GetByTopicPostNoBefore(topicId uint64, postNo uint64, limit int) (entities []*Entity)

func GetByTopicPostNoDesc

func GetByTopicPostNoDesc(topicId uint64, limit int) (entities []*Entity)

func GetFirstPageByTopicId

func GetFirstPageByTopicId(topicId uint64) (entities []*Entity)

func GetLastByTopicID added in v0.2.51

func GetLastByTopicID(topicID uint64) (entity Entity, ok bool)

func (*Entity) TableName

func (itself *Entity) TableName() string

func (Entity) WasPublished added in v0.2.74

func (e Entity) WasPublished() bool

Older replies predate moderation and were already published. Preserve that fact when they are first edited under the new schema.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL