user

package
v0.0.0-...-7daae65 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateAdminExists

func ValidateAdminExists(db *gorm.DB, objectName string) validation.RuleFunc

func ValidateEmailUniqueness

func ValidateEmailUniqueness(db *gorm.DB, toInsert bool, id int) validation.RuleFunc

func ValidateUserExistence

func ValidateUserExistence(db *gorm.DB, toInsert bool) validation.RuleFunc

func ValidateUserProfileConstraint

func ValidateUserProfileConstraint(db *gorm.DB, toInsert bool, profileId int) validation.RuleFunc

One profile per user - Used when updating

Types

type User

type User struct {
	models.BaseModelSoftDelete
	Email       string `db:"email" gorm:"unique_index;varchar(150);index:user_email_idx"`
	Role        int    `db:"role" gorm:"not null; default:1"`
	UserProfile *UserProfile
}

func LoadUserWithEmail

func LoadUserWithEmail(email string, db *gorm.DB) *User

func LoadUserWithId

func LoadUserWithId(id int, db *gorm.DB) *User

func (*User) BeforeCreate

func (toCreate *User) BeforeCreate(db *gorm.DB) (err error)

func (*User) BeforeUpdate

func (toUpdate *User) BeforeUpdate(db *gorm.DB) (err error)

func (*User) Create

func (toCreate *User) Create(db *gorm.DB) (*gorm.DB, error)

func (*User) Validate

func (u *User) Validate(db *gorm.DB, toInsert bool) error

type UserProfile

type UserProfile struct {
	models.BaseModelSoftDelete
	UserID    int     `db:"user_id" gorm:"index:user_id_profile_idx"`
	FirstName *string `db:"first_name"`
	LastName  *string `db:"last_name"`
}

func LoadUserProfile

func LoadUserProfile(userId int, db *gorm.DB) *UserProfile

func (*UserProfile) BeforeCreate

func (toCreate *UserProfile) BeforeCreate(db *gorm.DB) (err error)

func (*UserProfile) BeforeUpdate

func (toUpdate *UserProfile) BeforeUpdate(db *gorm.DB) (err error)

func (*UserProfile) Create

func (toCreate *UserProfile) Create(db *gorm.DB) (*gorm.DB, error)

func (*UserProfile) Validate

func (up *UserProfile) Validate(db *gorm.DB, toInsert bool) error

Jump to

Keyboard shortcuts

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