models

package
v0.0.0-...-7dc802a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSlug

func GenerateSlug(s string) string

GenerateSlug generate a slug from a string

func Now

func Now() *time.Time

Now ...

func TimeSetSQL

func TimeSetSQL(field string) string

TimeSetSQL ...

func TimeZeroSQL

func TimeZeroSQL(field string) string

TimeZeroSQL ...

func Unscoped

func Unscoped(db *gorm.DB) *gorm.DB

Unscoped ...

func UsersWithRole

func UsersWithRole(role string) func(db *gorm.DB) *gorm.DB

UsersWithRole users by role scope

Types

type Company

type Company struct {
	ID          int       `jsonapi:"primary,company" gorm:"primary_key"`
	Name        string    `jsonapi:"attr,name"`
	Slug        string    `jsonapi:"attr,slug"`
	Description string    `jsonapi:"attr,description"`
	Users       []*User   `jsonapi:"relation,users,omitempty" gorm:"save_associations:false"`
	CreatedAt   time.Time `json:"-"`
	UpdatedAt   time.Time `json:"-"`
}

Company company data structure

type Credential

type Credential struct {
	ID        int  `jsonapi:"primary,credential"`
	User      User `jsonapi:"relation,user"`
	UserID    int
	Source    SourceType `sql:"not null;type:ENUM('password', 'facebook', 'google', 'confirm_token')"`
	Value     string
	CreatedAt time.Time
	UpdatedAt time.Time
}

Credential credential data structure

type SourceType

type SourceType string

SourceType ...

const (
	// Password ...
	Password SourceType = "password"
	// ConfirmToken ...
	ConfirmToken SourceType = "confirm_token"
)

func (*SourceType) Scan

func (u *SourceType) Scan(value interface{}) error

Scan ...

func (SourceType) Value

func (u SourceType) Value() (driver.Value, error)

Value ...

type User

type User struct {
	ID           int       `jsonapi:"primary,user" gorm:"primary_key"`
	FirstName    string    `jsonapi:"attr,first_name" json:"first_name"`
	LastName     string    `jsonapi:"attr,last_name" json:"last_name"`
	Email        string    `jsonapi:"attr,email" valid:"email"`
	Password     string    `jsonapi:"attr,password,omitempty" gorm:"-" sql:"-" valid:"length(6|100)~Password must be at least 6 characters"`
	LastSigninAt time.Time `jsonapi:"attr,last_signin_at,iso8601"`
	CreatedAt    time.Time `jsonapi:"attr,created_at,iso8601"`
	UpdatedAt    time.Time `jsonapi:"attr,updated_at,iso8601"`
	ResetToken   string
	Source       string         `jsonapi:"attr,source,omitempty" gorm:"-" sql:"-"`
	Token        string         `jsonapi:"attr,token,omitempty" gorm:"-" sql:"-"`
	URL          string         `gorm:"-" sql:"-" jsonapi:"attr,url,omitempty"`
	Roles        pq.StringArray `jsonapi:"attr,roles"`
	RolesPayload []string       `jsonapi:"attr,roles_payload" gorm:"-" sql:"-"`
	CompanyID    int            `jsonapi:"attr,company_id,omitempty" json:"company_id"`
	Company      *Company       `jsonapi:"relation,company,omitempty" gorm:"save_associations:false"`
}

User type

func (*User) Find

func (u *User) Find(preloads ...string) error

Find find user by ID

func (*User) ForgotMergeVars

func (u *User) ForgotMergeVars() map[string]string

ForgotMergeVars ...

func (*User) FullName

func (u *User) FullName() string

FullName ...

func (*User) HasRole

func (u *User) HasRole(r string) bool

HasRole ...

func (*User) IsAdmin

func (u *User) IsAdmin() bool

IsAdmin ...

func (*User) JwtToken

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

JwtToken ...

func (*User) Login

func (u *User) Login() (*User, error)

Login ...

func (*User) MergeVars

func (u *User) MergeVars() map[string]string

MergeVars ...

func (*User) RegisterWithPassword

func (u *User) RegisterWithPassword() error

RegisterWithPassword ...

func (*User) SetResetPasswordToken

func (u *User) SetResetPasswordToken() error

SetResetPasswordToken ...

func (*User) UpdatePassword

func (u *User) UpdatePassword() error

UpdatePassword ...

func (*User) UpdatePasswordByResetToken

func (u *User) UpdatePasswordByResetToken() error

UpdatePasswordByResetToken ...

Jump to

Keyboard shortcuts

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