models

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

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

Go to latest
Published: Jan 4, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserStatusActive   = "active"
	UserStatusInactive = "inactive"
	UserStatusBanned   = "banned"

	MinPasswordLength = 8
	MaxPasswordLength = 72
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Role

type Role string
const (
	RoleAdmin Role = "admin"
	RoleUser  Role = "user"
)

type User

type User struct {
	ID        primitive.ObjectID `json:"id" bson:"_id,omitempty"`
	Name      string             `json:"name" bson:"name"`
	Email     string             `json:"email" bson:"email"`
	Password  string             `json:"password,omitempty" bson:"password"`
	Role      Role               `json:"role" bson:"role"`
	Status    string             `json:"status" bson:"status"`
	CreatedAt time.Time          `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time          `json:"updated_at" bson:"updated_at"`
}

func (*User) BeforeCreate

func (u *User) BeforeCreate() error

func (*User) BeforeUpdate

func (u *User) BeforeUpdate() error

func (*User) ComparePassword

func (u *User) ComparePassword(password string) error

func (*User) HashPassword

func (u *User) HashPassword() error

func (User) Validate

func (u User) Validate() error

func (*User) ValidateUpdate

func (u *User) ValidateUpdate() error

Jump to

Keyboard shortcuts

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