models

package
v0.0.0-...-594a47b Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB

Functions

func ConnectDatabase

func ConnectDatabase()

Types

type Comment

type Comment struct {
	ID        uint                        `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time                   `json:"created_at"`
	UpdatedAt time.Time                   `json:"updated_at"`
	PostID    uint                        `json:"post_id"`
	UserName  string                      `json:"user_name"`
	User      User                        `json:"-" gorm:"foreignKey:UserName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Content   string                      `json:"content"`
	Images    datatypes.JSONSlice[string] `json:"images"`
}

type Post

type Post struct {
	ID         uint                        `json:"id" gorm:"primaryKey"`
	CreatedAt  time.Time                   `json:"created_at"`
	UpdatedAt  time.Time                   `json:"updated_at"`
	UserName   string                      `json:"user_name" gorm:"index"`
	User       User                        `json:"-" gorm:"foreignKey:UserName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	Title      string                      `json:"title"`
	Content    string                      `json:"content"`
	Images     datatypes.JSONSlice[string] `json:"images"`
	Comments   []Comment                   `json:"comments" gorm:"foreignKey:PostID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	EmbedVideo string                      `json:"embed_video"`
}

func (*Post) Redact

func (post *Post) Redact()

type User

type User struct {
	Name        string    `json:"user_name" gorm:"constraint:OnUpdate:CASCADE,primaryKey"`
	DisplayName string    `json:"display_name"`
	Password    []byte    `json:"-" gorm:"type:BINARY(60)"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	Posts       []Post    `json:"posts" gorm:"foreignKey:UserName;references:Name"`
}

Jump to

Keyboard shortcuts

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