model

package
v1.6.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: MIT Imports: 7 Imported by: 10

Documentation

Overview

Package model contains all the models required for a functional database management system

Index

Constants

View Source
const (
	EmailNotVerified       int8 = -1
	EmailVerifyNotRequired int8 = 0
	EmailVerified          int8 = 1
)

Email verification statuses

View Source
const (
	EmailTypeVerification int = 1
	EmailTypePassRecovery int = 2
)

Email type

View Source
const (
	EmailVerificationKeyPrefix string = "gorest-email-verification-"
	PasswordRecoveryKeyPrefix  string = "gorest-pass-recover-"
)

Redis key prefixes

Variables

View Source
var InMemorySecret2FA = make(map[uint64]Secret2FA)

InMemorySecret2FA - keep secrets temporarily in memory to setup 2FA

Functions

This section is empty.

Types

type Auth

type Auth struct {
	AuthID      uint64         `gorm:"primaryKey" json:"authID,omitempty"`
	CreatedAt   time.Time      `json:"createdAt,omitempty"`
	UpdatedAt   time.Time      `json:"updatedAt,omitempty"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"-"`
	Email       string         `json:"email"`
	Password    string         `json:"password"`
	VerifyEmail int8           `json:"-"`
}

Auth model - `auths` table

func (Auth) MarshalJSON

func (v Auth) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Auth) UnmarshalJSON

func (v *Auth) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

type ErrorMsg added in v1.4.0

type ErrorMsg struct {
	HTTPCode int    `structs:"httpResponseCode" json:"-"`
	Message  string `structs:"msg" json:"msg"`
}

ErrorMsg ...

type Hobby

type Hobby struct {
	HobbyID   uint64         `gorm:"primaryKey" json:"hobbyID,omitempty"`
	CreatedAt time.Time      `json:"createdAt,omitempty"`
	UpdatedAt time.Time      `json:"updatedAt,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	Hobby     string         `json:"hobby,omitempty"`
	Users     []User         `gorm:"many2many:user_hobbies" json:"-"`
}

Hobby model - `hobbies` table

type Post

type Post struct {
	PostID    uint64         `gorm:"primaryKey" json:"postID,omitempty" structs:"postID,omitempty"`
	CreatedAt time.Time      `json:"createdAt,omitempty" structs:"createdAt,omitempty"`
	UpdatedAt time.Time      `json:"updatedAt,omitempty" structs:"updatedAt,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	Title     string         `json:"title,omitempty" structs:"title,omitempty"`
	Body      string         `json:"body,omitempty" structs:"body,omitempty"`
	IDUser    uint64         `json:"-"`
}

Post model - `posts` table

type Secret2FA added in v1.6.1

type Secret2FA struct {
	PassSHA []byte `json:"-"`
	Secret  []byte `json:"-"`
	Image   string `json:"-"`
}

Secret2FA - save encoded secrets in RAM temporarily

type TwoFA added in v1.6.1

type TwoFA struct {
	ID        uint64         `gorm:"primaryKey" json:"-"`
	CreatedAt time.Time      `json:"-"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	KeyMain   string         `json:"-"`
	KeyBackup string         `json:"-"`
	UUIDSHA   string         `json:"-"`
	UUIDEnc   string         `json:"-"`
	Status    string         `json:"-"`
	IDAuth    uint64         `json:"-"`
}

TwoFA model - 'two_fas' table

type User

type User struct {
	UserID    uint64         `gorm:"primaryKey" json:"userID,omitempty"`
	CreatedAt time.Time      `json:"createdAt,omitempty"`
	UpdatedAt time.Time      `json:"updatedAt,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	FirstName string         `json:"firstName,omitempty"`
	LastName  string         `json:"lastName,omitempty"`
	IDAuth    uint64         `json:"-"`
	Posts     []Post         `gorm:"foreignkey:IDUser;references:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"posts,omitempty"`
	Hobbies   []Hobby        `gorm:"many2many:user_hobbies" json:"hobbies,omitempty"`
}

User model - `users` table

type UserHobby

type UserHobby struct{}

UserHobby model - intermediate table `user_hobbies` (many to many relations)

Jump to

Keyboard shortcuts

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