Documentation ¶
Index ¶
- Constants
- Variables
- func Connect() (err error)
- type Role
- type Session
- type Setting
- type User
- func (u *User) BeforeCreate(tx *gorm.DB) error
- func (u *User) BeforeSave(tx *gorm.DB) error
- func (u *User) Create() error
- func (u *User) Delete() error
- func (u *User) List(flags int) ([]User, error)
- func (u *User) Read(flags int) error
- func (u *User) Update() error
- func (u *User) ValidatePassword(password string) error
Constants ¶
View Source
const (
PreloadRole = 1 << iota
)
Variables ¶
View Source
var DB *gorm.DB
View Source
var ErrPasswordRequired = errors.New("password required for user")
Functions ¶
Types ¶
type Role ¶
type Session ¶
type Session struct { ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"-"` UpdatedAt time.Time `json:"-"` UserID uuid.UUID `gorm:"type:uuid;uniqueIndex" json:"id"` FirstName string `gorm:"-" json:"firstName"` LastName string `gorm:"-" json:"lastName"` Role string `gorm:"-" json:"role"` Token string `json:"token,omitempty"` }
type Setting ¶
type User ¶
type User struct { ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"` FirstName string `gorm:"not null" json:"firstName"` LastName string `gorm:"not null" json:"lastName"` Email string `gorm:"uniqueIndex;not null" json:"email"` Password string `gorm:"not null" json:"-"` RoleID uint `json:"-"` Role *Role `gorm:"constraint:OnDelete:SET NULL" json:"role,omitempty"` Session *Session `gorm:"constraint:OnDelete:SET NULL" json:"session,omitempty"` RawPassword string `gorm:"-" json:"password,omitempty"` }
func (*User) ValidatePassword ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.