model

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Like added in v0.0.3

type Like struct {
	bun.BaseModel `bun:"table:Like"`

	UserID int `bun:"user_id,pk,nullzero"`
	PostID int `bun:"post_id,pk,nullzero"`
}

type Post

type Post struct {
	bun.BaseModel `bun:"table:posts"`

	ID        int       `bun:"id,pk,nullzero"`
	CreatedAt time.Time `bun:"created_at,notnull,nullzero"`
	UpdatedAt time.Time `bun:"updated_at,notnull,nullzero"`
	Published bool      `bun:"published,notnull,nullzero"`
	Title     string    `bun:"title,notnull,nullzero"`
	Author    User      `bun:"rel:belongs-to,join:author_id=id"`
	AuthorID  int       `bun:"author_id,notnull,nullzero"`
}

type Role

type Role string
const (
	RoleUser  Role = "USER"
	RoleAdmin Role = "ADMIN"
)

type User

type User struct {
	bun.BaseModel `bun:"table:User"`

	ID        int       `bun:"id,pk,nullzero"`
	Name      string    `bun:"name,nullzero"`
	Email     string    `bun:"email,notnull,unique,nullzero"`
	CreatedAt time.Time `bun:"created_at,notnull,nullzero"`
	Role      Role      `bun:"role,notnull,nullzero"`
	Posts     []Post    `bun:"rel:has-many"`
}

Jump to

Keyboard shortcuts

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