Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseModel ¶
BaseModel is base class for all models, created for flexibility later,
- currently same as gorm.Model
type DeleterSaver ¶
type DeleterSaver interface { Delete(bool) Save() }
DeleterSaver interface to define methods for base models with ID
type User ¶
type User struct { BaseModel GoogleID string `gorm:"unique_index;default:null;"` FacebookID string `gorm:"unique_index;default:null;"` Password string `gorm:"default:null;"` FirstName string `gorm:"not null"` LastName string `gorm:"not null"` Email string `gorm:"type:varchar(100);unique_index;not null;"` EmailVerifiedAt time.Time Role uint `gorm:"default:1;"` }
User is a base model of user
func CheckCredentials ¶
CheckCredentials returns user if email-password combination exists, otherwise null
func GetUserByEmail ¶
GetUserByEmail returns user with given email if exists, otherwise null
func (*User) Delete ¶
Delete deletes user, softDelete parameter specifies whether value should be deleted permanently
*Primary key (ID) must be set
func (*User) Save ¶
func (u *User) Save()
Save updates model in the database, if primary key isn't set creates model
func (*User) SaveUserIfDoesntExist ¶
func (u *User) SaveUserIfDoesntExist()
SaveUserIfDoesntExist saves user to database if emails isn't occupied
Click to show internal directories.
Click to hide internal directories.