models

package
v0.0.0-...-c48e8af Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(password string) string

Types

type Post

type Post struct {
	gorm.Model
	Title string `gorm:"column:title;size:255;not null;" json:"title" validate:"required"`
	Body  string `gorm:"column:body;not null;" json:"body" validate:"required"`

	UserID uint `gorm:"column:user_id;not null;"`
	User   User `gorm:"foreignKey:UserID;references:ID;"`
}

type Posts

type Posts []Post

type Profile

type Profile struct {
	gorm.Model

	PhoneNumber string `gorm:"column:phone_number;null;"`
	Gender      string `gorm:"column:gender;null;"`

	UserID uint `gorm:"column:user_id;not null;"`
}

type User

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

	Profile Profile `gorm:"foreignKey:UserID;references:ID" json:"profile"`
	Posts   []Post  `gorm:"foreignKey:UserID;references:ID" json:"posts"`
}

func (*User) BeforeCreate

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

type Users

type Users = []User

Jump to

Keyboard shortcuts

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