model

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID        int64  `gorm:"primaryKey;" json:"id"`
	CreatedAt int64  `gorm:"index:idx_created_at,sort:desc;autoCreateTime;" json:"created_at"`
	Video     Video  `gorm:"foreignKey:VideoID;references:ID;" json:"video"`
	VideoID   int64  `gorm:"index:idx_video_id;" json:"video_id"`
	User      User   `gorm:"foreignKey:UserID;references:ID;" json:"user"`
	UserID    int64  `gorm:"index:idx_user_id;" json:"user_id"`
	Content   string `gorm:"type:varchar(255);not null;" json:"content"`
}

Comment belongs to Video and User

type FavoriteRelation

type FavoriteRelation struct {
	ID      int64 `gorm:"primaryKey;" json:"id"`
	User    User  `gorm:"foreignKey:UserID;references:ID;" json:"user"`
	UserID  int64 `gorm:"uniqueIndex:idx_rel;" json:"user_id"`
	Video   Video `gorm:"foreignKey:VideoID;references:ID;" json:"video"`
	VideoID int64 `gorm:"uniqueIndex:idx_rel;" json:"video_id"`
}

FavoriteRelation unique multi-column index for user id and video id

type FollowRelation

type FollowRelation struct {
	ID       int64 `gorm:"primaryKey;" json:"id"`
	User     User  `gorm:"foreignKey:UserID;references:ID;" json:"user"`
	UserID   int64 `gorm:"uniqueIndex:idx_rel;" json:"user_id"`
	ToUser   User  `gorm:"foreignKey:ToUserID;references:ID;" json:"to_user"`
	ToUserID int64 `gorm:"uniqueIndex:idx_rel;index:idx_to_user_id;" json:"to_user_id"`
}

FollowRelation unique multi-column index for user id and to user id extra single index for to user id

type User

type User struct {
	ID             int64  `gorm:"primaryKey;" json:"id"`
	Username       string `gorm:"uniqueIndex:idx_user_name;type:varchar(31);" json:"username"`
	Password       string `gorm:"type:varchar(63);not null;" json:"password"`
	FollowingCount int64  `gorm:"default:0;" json:"following_count"`
	FollowerCount  int64  `gorm:"default:0;" json:"follower_count"`
}

User Many To Many (User, Video)

type Video

type Video struct {
	ID            int64  `gorm:"primaryKey;" json:"id"`
	CreatedAt     int64  `gorm:"index:idx_created_at,sort:desc;autoCreateTime;" json:"created_at"` // 使用时间戳秒数填充创建时间
	Author        User   `gorm:"foreignKey:AuthorID;references:ID;" json:"author"`
	AuthorID      int64  `gorm:"index:idx_author_id;" json:"author_id"`
	PlayUrl       string `gorm:"type:varchar(511);not null;" json:"play_url"`
	CoverUrl      string `gorm:"type:varchar(511);" json:"cover_url"`
	FavoriteCount int64  `gorm:"default:0;" json:"favorite_count"`
	CommentCount  int64  `gorm:"default:0;" json:"comment_count"`
	Title         string `gorm:"type:varchar(63);not null;" json:"title"`
}

Video belongs to User

func (Video) TableName

func (Video) TableName() string

Jump to

Keyboard shortcuts

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