models

package
v0.0.0-...-31041b1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2020 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB

func CloseDB() error

CloseDB connection

func ComparePasswords

func ComparePasswords(hashedPwd string, plainPwd []byte) bool

ComparePasswords with plain pw

func GetDB

func GetDB() *gorm.DB

GetDB connection

func Init

func Init()

Init db

Types

type CreateUserRequest

type CreateUserRequest struct {
	Email    string `json:"email" valid:"required,email"`
	Name     string `json:"name" valid:"required,stringlength(2|50)"`
	Username string `json:"username" valid:"required,stringlength(2|50)"`
	Password string `json:"password" valid:"required,stringlength(8|50)"`
}

CreateUserRequest type

type LogingUserRequest

type LogingUserRequest struct {
	Email    string `json:"email" valid:"required,email"`
	Password string `json:"password" valid:"required"`
}

LogingUserRequest type

type User

type User struct {
	ID       uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	Name     string    `gorm:"not null;default: null" json:"name"`
	Username string    `gorm:"unique;not null;default: null" json:"username"`
	Password string    `gorm:"type:varchar(255);not null;default: null" json:"password"`
	Email    string    `gorm:"type:varchar(100);unique_index;default: null" json:"email"`
	Role     string    `gorm:"not null;default: null" json:"role"`
}

User model

func (*User) BeforeCreate

func (u *User) BeforeCreate(scope *gorm.Scope) error

BeforeCreate will set a UUID rather than numeric ID.

func (*User) BeforeSave

func (u *User) BeforeSave() (err error)

BeforeSave func

Jump to

Keyboard shortcuts

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