Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ModelComment ¶
type ModelComment struct {
bun.BaseModel `bun:"table:comments,alias:c"`
ID int64 `bun:"id,pk,autoincrement,type:bigint"`
PostID int64 `bun:"post_id,notnull,type:bigint"`
UserID *int64 `bun:"user_id,type:bigint"`
Content string `bun:"content,notnull,type:text"`
CreatedAt time.Time `bun:"created_at,type:timestamp"`
UpdatedAt time.Time `bun:"updated_at,type:timestamp"`
Post *ModelPost `bun:"rel:belongs-to,join:post_id=id"`
User *ModelUser `bun:"rel:belongs-to,join:user_id=id"`
}
ModelComment represents a comment on a post
type ModelPost ¶
type ModelPost struct {
bun.BaseModel `bun:"table:posts,alias:p"`
ID int64 `bun:"id,pk,autoincrement,type:bigint"`
UserID int64 `bun:"user_id,notnull,type:bigint"`
Title string `bun:"title,notnull,type:varchar(255)"`
Slug string `bun:"slug,notnull,type:varchar(255),unique:idx_slug"`
Content string `bun:"content,notnull,type:text"`
Excerpt *string `bun:"excerpt,type:text"`
Published bool `bun:"published,type:boolean"`
ViewCount int64 `bun:"view_count,type:bigint"`
PublishedAt *time.Time `bun:"published_at,type:timestamp,nullzero"`
CreatedAt time.Time `bun:"created_at,type:timestamp"`
UpdatedAt time.Time `bun:"updated_at,type:timestamp"`
User *ModelUser `bun:"rel:belongs-to,join:user_id=id"`
Comments []*ModelComment `bun:"rel:has-many,join:id=post_id"`
}
ModelPost represents a blog post
type ModelUser ¶
type ModelUser struct {
bun.BaseModel `bun:"table:users,alias:u"`
ID int64 `bun:"id,pk,autoincrement,type:bigint"`
Username string `bun:"username,notnull,type:varchar(100),unique:idx_username"`
Email string `bun:"email,notnull,type:varchar(255),unique"`
Password string `bun:"password,notnull,type:varchar(255)"`
FirstName *string `bun:"first_name,type:varchar(100)"`
LastName *string `bun:"last_name,type:varchar(100)"`
Bio *string `bun:"bio,type:text"`
IsActive bool `bun:"is_active,type:boolean"`
CreatedAt time.Time `bun:"created_at,type:timestamp"`
UpdatedAt time.Time `bun:"updated_at,type:timestamp"`
Posts []*ModelPost `bun:"rel:has-many,join:id=user_id"`
}
ModelUser represents a user in the system
type User ¶
type User struct {
bun.BaseModel `bun:"table:users,alias:u"`
ID int64 `bun:"id,pk,autoincrement,type:bigint"`
Email string `bun:"email,notnull,type:varchar(255),unique"`
Name string `bun:"name,type:text"`
Age *int `bun:"age,type:integer"`
IsActive bool `bun:"is_active,type:boolean"`
CreatedAt time.Time `bun:"created_at,type:timestamp,default:now()"`
}
Click to show internal directories.
Click to hide internal directories.