models

package
v0.0.0-...-d7b6ce4 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 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 BasicModel

type BasicModel struct {
	ID        uint           `json:"id" gorm:"primarykey"`
	CreatedAt time.Time      `json:"-"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}

type Example

type Example struct {
	BasicModel

	Name   string `json:"name"`                         // Name
	Status string `json:"status" gorm:"default:active"` // Status, active or inactive
}

type Setting

type Setting struct {
	BasicModel

	Key         string      `gorm:"primaryKey"`
	Value       string      `gorm:"not null"`
	Type        SettingType `gorm:"not null"`
	Title       string
	Description string
}

Setting represents the settings table in the database

func (*Setting) GetValue

func (s *Setting) GetValue() (interface{}, error)

GetValue retrieves the value of the setting based on the type

func (*Setting) MarshalJSON

func (s *Setting) MarshalJSON() ([]byte, error)

func (*Setting) UnmarshalJSON

func (s *Setting) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the JSON data into the setting

type SettingType

type SettingType int
const (
	TypeString SettingType = iota
	TypeInt
	TypeFloat
	TypeBool
	TypeJSON
)

type User

type User struct {
	BasicModel

	Name          datatypes.NullString `json:"name"`                        // Name
	Username      datatypes.NullString `json:"username" gorm:"uniqueIndex"` // Username
	Password      datatypes.NullString `json:"-"`                           // Password
	Phone         datatypes.NullString `json:"phone" gorm:"uniqueIndex"`    // Phone
	Email         datatypes.NullString `json:"email" gorm:"uniqueIndex"`    // Email
	EmailVerified bool                 `json:"email_verified"`
	LastLoginAt   time.Time            `json:"-"` // Last login time
	Dob           datatypes.Date       `json:"dob"`
}

Jump to

Keyboard shortcuts

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