models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	ID   string `db:"id,primaryKey,size:36"`
	Name string `db:"name"`
}

...

func (Category) TableName

func (Category) TableName() string

type Post

type Post struct {
	ID        int64                   `db:"id,primaryKey,autoIncrement"`
	UserID    int64                   `db:"user_id"`
	Title     string                  `db:"title,size:200"`
	Content   string                  `db:"content"`
	Metadata  sqlc.JSON[PostMetadata] `db:"metadata,type:json"` // JSON field with type:json tag
	CreatedAt time.Time               `db:"created_at"`
	UpdatedAt time.Time               `db:"updated_at"`
}

type PostMetadata

type PostMetadata struct {
	ViewCount    int      `json:"view_count"`
	LikeCount    int      `json:"like_count"`
	Tags         []string `json:"tags"`
	IsFeatured   bool     `json:"is_featured"`
	CategoryName string   `json:"category_name"`
}

PostMetadata represents the JSON metadata for a post

type User

type User struct {
	ID        int64     `db:"id,primaryKey,autoIncrement"`
	Username  string    `db:"username,size:100,unique"`
	Email     string    `db:"email,size:255,index"`
	CreatedAt time.Time `db:"created_at"`
}

func (*User) AfterCreate

func (u *User) AfterCreate(ctx context.Context) error

func (*User) BeforeCreate

func (u *User) BeforeCreate(ctx context.Context) error

func (User) TableName

func (User) TableName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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