models

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangePasswordRequest

type ChangePasswordRequest struct {
	Password    string `json:"password"`
	NewPassword string `json:"new_password"`
}

type Entry

type Entry struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`

	HabitID uint      `gorm:"index" json:"habit_id"`
	Date    time.Time `gorm:"index" json:"date"`
}

type Habit

type Habit struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`

	Name    string  `gorm:"size:128;not null" json:"name"`
	UserID  uint    `gorm:"index" json:"user_id"`
	Entries []Entry `json:"-"`
}

type HabitAllResponse added in v0.2.0

type HabitAllResponse struct {
	ID             uint       `json:"id"`
	Name           string     `json:"name"`
	CreatedAt      time.Time  `json:"created_at"`
	LastActivity   *time.Time `json:"last_activity"`
	CompletedToday bool       `json:"completed_today"`
}

type HabitRequest

type HabitRequest struct {
	Name string `json:"name"`
}

func (*HabitRequest) GetHabitStruct

func (req *HabitRequest) GetHabitStruct() *Habit

type HabitResponse

type HabitResponse struct {
	ID        uint      `gorm:"primaryKey" json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	UserID    uint      `json:"user_id"`

	// Stats
	EntriesCount  int64 `gorm:"-:all" json:"entries_count"`
	Streak        uint  `gorm:"-:all" json:"streak"`
	LongestStreak uint  `gorm:"-:all" json:"longest_streak"`
}

type PatchUserRequest added in v0.3.0

type PatchUserRequest struct {
	Timezone string `json:"timezone"`
}

type Streak added in v0.2.0

type Streak struct {
	Streak  uint
	MinDate string
	MaxDate string
}

type User

type User struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`

	Name         string  `gorm:"size:128;not null" json:"name"`
	Email        string  `gorm:"size:128;not null;uniqueIndex" json:"email"`
	Admin        bool    `gorm:"not null;default:false;index" json:"admin"`
	Password     string  `gorm:"-" json:"-"`
	PasswordHash string  `gorm:"not null" json:"-"`
	Timezone     string  `gorm:"size:128;not null;default:UTC" json:"timezone"`
	Habits       []Habit `json:"-"`
}

func (*User) CheckPasswordHash

func (u *User) CheckPasswordHash() bool

func (*User) HashPassword

func (u *User) HashPassword() (string, error)

func (*User) Validate

func (u *User) Validate() error

func (*User) ValidatePassword

func (u *User) ValidatePassword() error

type UserLogin

type UserLogin struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

func (*UserLogin) GetUserStruct

func (login *UserLogin) GetUserStruct() *User

type UserRequest

type UserRequest struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`
	Admin    bool   `json:"admin"`
	Timezone string `json:"timezone"`
}

func (*UserRequest) GetUserStruct

func (req *UserRequest) GetUserStruct() *User

Jump to

Keyboard shortcuts

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