model

package
v0.0.0-...-747ec1c Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Author

type Author struct {
	gorm.Model

	ID          int    `gorm:"primaryKey" json:"id"`
	Name        string `gorm:"unique" json:"name"`
	Description string `json:"description"`
	IsActive    bool   `json:"is_active"`
	IsSuperuser bool   `json:"is_superuser"`
}

func (*Author) IsDeleted

func (a *Author) IsDeleted() bool

type Category

type Category struct {
	gorm.Model

	ID          int       `gorm:"primaryKey" json:"id"`
	Name        string    `gorm:"size:255" json:"name"`
	Description string    `gorm:"type:text" json:"description"`
	ParentID    *int      `gorm:"index;default:NULL" json:"parent_id"`
	Parent      *Category `gorm:"foreignKey:ParentID"`
	Quotes      []Quote   `gorm:"many2many:quote_categories"`
}

func (*Category) BeforeCreate

func (category *Category) BeforeCreate(tx *gorm.DB) (err error)

Ensure foreign key constraints are applied on migrations.

func (*Category) IsDeleted

func (q *Category) IsDeleted() bool

type Quote

type Quote struct {
	gorm.Model

	ID           int        `gorm:"primaryKey" json:"id"`
	QText        string     `gorm:"column:qtext;type:varchar(255);not null" json:"text"`
	Tags         string     `gorm:"column:tags;type:varchar(255);not null" json:"tags"`
	AuthorID     *int       `json:"author_id"`
	Author       Author     `json:"author"`
	Categories   []Category `gorm:"many2many:quote_categories"`
	UserWhoLiked []User     `gorm:"many2many:quote_likes" json:"users_who_liked"`
}

func (*Quote) IsDeleted

func (q *Quote) IsDeleted() bool

func (*Quote) LikedCount

func (q *Quote) LikedCount() int

type User

type User struct {
	gorm.Model

	ID          int     `gorm:"primaryKey" json:"id"`
	Username    string  `gorm:"unique" json:"username"`
	Password    string  `json:"-"`
	FullName    string  `json:"name"`
	Email       string  `gorm:"unique" json:"email"`
	Phone       string  `json:"phone"`
	Level       string  `json:"level"`
	IsActive    bool    `json:"is_active"`
	IsSuperuser bool    `json:"is_superuser"`
	LikedQuotes []Quote `gorm:"many2many:quote_likes"`
}

func (*User) IsDeleted

func (u *User) IsDeleted() bool

Jump to

Keyboard shortcuts

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