models

package
v0.0.0-...-042b7a9 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnonymousUser = &User{}

Functions

func HashPassword

func HashPassword(password string) string

Types

type BlogPost

type BlogPost struct {
	gorm.Model

	Title  string `gorm:"column:title;size:200;not null;"`
	Body   string `gorm:"column:body;not null;"`
	UserID uint   `gorm:"column:user_id;not null;"`
	User   User   `gorm:"foreignKey:UserID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

type BlogPosts

type BlogPosts []BlogPost

type Comment

type Comment struct {
	gorm.Model

	Body   string   `gorm:"column:body;not null;"`
	UserID uint     `gorm:"column:user_id;not null;"`
	User   User     `gorm:"foreignKey:UserID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	PostID uint     `gorm:"column:post_id;not null;"`
	Post   BlogPost `gorm:"foreignKey:PostID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

type Comments

type Comments []Comment

type Follower

type Follower struct {
	gorm.Model

	UserID     uint `gorm:"column:user_id;not null;"`
	User       User `gorm:"foreignKey:UserID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	FollowerID uint `gorm:"column:follower_id;not null;"`
	Follower   User `gorm:"foreignKey:FollowerID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

type User

type User struct {
	gorm.Model
	Email    string `gorm:"column:email;not null;index;" json:"email" validate:"required"`
	Name     string `gorm:"column:name;size:64;not null;" json:"name" validate:"required"`
	Password string `gorm:"column:password;not null;" json:"-" validate:"required"`
}

func (*User) BeforeCreate

func (m *User) BeforeCreate(_ *gorm.DB) (err error)

func (*User) BeforeUpdate

func (m *User) BeforeUpdate(_ *gorm.DB) (err error)

func (*User) CheckPassword

func (m *User) CheckPassword(plain string) (bool, error)

func (*User) IsAnonymous

func (m *User) IsAnonymous() bool

type Users

type Users []User

Jump to

Keyboard shortcuts

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