models

package
v0.0.0-...-e0091a7 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(password string) ([]byte, error)

Hash is...

func VerifyPassword

func VerifyPassword(hashedPassowrd, password string) error

VerifyPassword is...

Types

type Post

type Post struct {
	ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Title     string    `gorm:"size:255;not null;unique" json:"title"`
	Content   string    `gorm:"size:255;not null;" json:"content"`
	Author    User      `json:"author"`
	AuthorID  uint32    `gorm:"not null" json:"author_id"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

Post is...

func (*Post) Create

func (p *Post) Create(db *gorm.DB) (*Post, error)

Create is...

func (*Post) DeletePost

func (p *Post) DeletePost(db *gorm.DB, pid uint32, uid uint32) (int64, error)

DeletePost is...

func (*Post) FindAllPosts

func (p *Post) FindAllPosts(db *gorm.DB) (*[]Post, error)

FindAllPosts is...

func (*Post) FindPostByID

func (p *Post) FindPostByID(db *gorm.DB, pid uint32) (*Post, error)

FindPostByID is...

func (*Post) Prepare

func (p *Post) Prepare()

Prepare is...

func (*Post) UpdatePost

func (p *Post) UpdatePost(db *gorm.DB) (*Post, error)

UpdatePost is...

func (*Post) Validate

func (p *Post) Validate() error

Validate is...

type User

type User struct {
	ID        uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Nickname  string    `gorm:"size:255;not null;unique" json:"nickname"`
	Email     string    `gorm:"size:100;not null;unique" json:"email"`
	Password  string    `gorm:"size:100;not null;" json:"password"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

User is...

func (*User) BeforeSave

func (u *User) BeforeSave() error

BeforeSave is...

func (*User) DeleteUser

func (u *User) DeleteUser(db *gorm.DB, uid uint32) (int64, error)

DeleteUser is...

func (*User) FindAllUsers

func (u *User) FindAllUsers(db *gorm.DB) (*[]User, error)

FindAllUsers is...

func (*User) FindUserByID

func (u *User) FindUserByID(db *gorm.DB, uid uint32) (*User, error)

FindUserByID is...

func (*User) Prepare

func (u *User) Prepare() error

Prepare is...

func (*User) SaveUser

func (u *User) SaveUser(db *gorm.DB) (*User, error)

SaveUser is...

func (*User) UpdateUser

func (u *User) UpdateUser(db *gorm.DB, uid uint32) (*User, error)

UpdateUser is...

func (*User) Validate

func (u *User) Validate(action string) error

Validate is...

Jump to

Keyboard shortcuts

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