model

package
v0.0.0-...-271498a Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPass

func HashPass(pass string) string

HashPass ...

Types

type Auth

type Auth struct {
	AuthID    uint64 `gorm:"primaryKey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
	Email     string         `json:"Email"`
	Password  string         `json:"Password"`
	User      User           `gorm:"foreignkey:IDAuth;references:AuthID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

Auth model - `auths` table

func (Auth) MarshalJSON

func (v Auth) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Auth) UnmarshalJSON

func (v *Auth) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type ErrorMsg

type ErrorMsg struct {
	HTTPCode int    `structs:"http_response_code" json:"-"`
	Message  string `structs:"msg" json:"msg"`
}

ErrorMsg ...

type Hobby

type Hobby struct {
	HobbyID   uint64 `gorm:"primaryKey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	Hobby     string         `json:"Hobby,omitempty"`
	Users     []User         `gorm:"many2many:user_hobbies" json:"-"`
}

Hobby model - `hobbies` table

type Post

type Post struct {
	PostID    uint64 `gorm:"primaryKey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	Title     string         `json:"Title,omitempty"`
	Body      string         `json:"Body,omitempty"`
	IDUser    uint64         `json:"-"`
}

Post model - `posts` table

type User

type User struct {
	UserID    uint64 `gorm:"primaryKey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	FirstName string         `json:"FirstName,omitempty"`
	LastName  string         `json:"LastName,omitempty"`
	IDAuth    uint64         `json:"-"`
	Posts     []Post         `gorm:"foreignkey:IDUser;references:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:",omitempty"`
	Hobbies   []Hobby        `gorm:"many2many:user_hobbies" json:",omitempty"`
}

User model - `users` table

type UserHobby

type UserHobby struct{}

UserHobby model - intermediate table `user_hobbies` (many to many relations)

Jump to

Keyboard shortcuts

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