models

package
v0.0.0-...-bbcf6c5 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 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: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 Posts

type Posts []Post

type Profile

type Profile struct {
	gorm.Model

	PhoneNumber string `gorm:"column:phone_number;null;"`
	Gender      string `gorm:"column:gender;not 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;"`
	Posts   []Post  `gorm:"foreignKey:UserID;references:ID;"`
}

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