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"`
}
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"`
}
Click to show internal directories.
Click to hide internal directories.