Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ModelComment ¶
type ModelComment struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement;type:bigint"`
PostID int64 `gorm:"column:post_id;type:bigint;not null;index:idx_post_id"`
UserID *int64 `gorm:"column:user_id;type:bigint;index:idx_user_id"`
Content string `gorm:"column:content;type:text;not null"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:now()"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:now()"`
Post *ModelPost `gorm:"foreignKey:PostID;references:ID;constraint:OnDelete:CASCADE"`
User *ModelUser `gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:SET NULL"`
}
ModelComment represents a comment on a post
func (ModelComment) TableName ¶
func (ModelComment) TableName() string
type ModelPost ¶
type ModelPost struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement;type:bigint"`
UserID int64 `gorm:"column:user_id;type:bigint;not null;index:idx_user_id"`
Title string `gorm:"column:title;type:varchar(255);not null"`
Slug string `gorm:"column:slug;type:varchar(255);not null;uniqueIndex:idx_slug"`
Content string `gorm:"column:content;type:text;not null"`
Excerpt *string `gorm:"column:excerpt;type:text"`
Published bool `gorm:"column:published;type:boolean;default:false"`
ViewCount int64 `gorm:"column:view_count;type:bigint;default:0"`
PublishedAt *time.Time `gorm:"column:published_at;type:timestamp"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:now()"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:now()"`
User *ModelUser `gorm:"foreignKey:UserID;references:ID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
Comments []*ModelComment `gorm:"foreignKey:PostID;association_foreignkey:ID;constraint:OnDelete:CASCADE"`
}
ModelPost represents a blog post
type ModelUser ¶
type ModelUser struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement;type:bigint"`
Username string `gorm:"column:username;type:varchar(100);not null;uniqueIndex:idx_username"`
Email string `gorm:"column:email;type:varchar(255);not null;uniqueIndex"`
Password string `gorm:"column:password;type:varchar(255);not null"`
FirstName *string `gorm:"column:first_name;type:varchar(100)"`
LastName *string `gorm:"column:last_name;type:varchar(100)"`
Bio *string `gorm:"column:bio;type:text"`
IsActive bool `gorm:"column:is_active;type:boolean;default:true"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:now()"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp;default:now()"`
Posts []*ModelPost `gorm:"foreignKey:UserID;association_foreignkey:ID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE"`
Comments []*ModelComment `gorm:"foreignKey:UserID;association_foreignkey:ID;constraint:OnDelete:SET NULL"`
}
ModelUser represents a user in the system
type User ¶
type User struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement;type:bigint"`
Email string `gorm:"column:email;type:varchar(255);not null"`
Name string `gorm:"column:name;type:text"`
Age *int `gorm:"column:age;type:integer"`
IsActive bool `gorm:"column:is_active;type:boolean"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp;default:now()"`
}
Click to show internal directories.
Click to hide internal directories.