database

package
v0.0.0-...-86fa0e8 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PreloadRole = 1 << iota
)

Variables

View Source
var DB *gorm.DB
View Source
var ErrPasswordRequired = errors.New("password required for user")

Functions

func Connect

func Connect() (err error)

Types

type Role

type Role struct {
	ID        uint            `gorm:"primaryKey" json:"id"`
	CreatedAt time.Time       `json:"createdAt"`
	UpdatedAt time.Time       `json:"updatedAt"`
	DeletedAt *gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"`
	Name      string          `gorm:"uniqueIndex;not null" json:"name"`
	IsAdmin   bool            `json:"isAdmin"`
}

func (*Role) Create

func (r *Role) Create() error

func (*Role) Read

func (r *Role) Read() error

type Session

type Session struct {
	ID        uuid.UUID `gorm:"type:uuid;primaryKey" json:"-"`
	UpdatedAt time.Time `json:"-"`
	UserID    uuid.UUID `gorm:"type:uuid;uniqueIndex" json:"id"`
	FirstName string    `gorm:"-" json:"firstName"`
	LastName  string    `gorm:"-" json:"lastName"`
	Role      string    `gorm:"-" json:"role"`
	Token     string    `json:"token,omitempty"`
}

func (*Session) BeforeCreate

func (s *Session) BeforeCreate(tx *gorm.DB) error

func (*Session) Read

func (s *Session) Read() error

func (*Session) Upsert

func (s *Session) Upsert() error

type Setting

type Setting struct {
	ID        uint              `gorm:"primaryKey" json:"id"`
	CreatedAt time.Time         `json:"createdAt"`
	UpdatedAt time.Time         `json:"updatedAt"`
	DeletedAt *gorm.DeletedAt   `gorm:"index" json:"deletedAt,omitempty"`
	Key       string            `gorm:"uniqueIndex;not null"`
	Value     datatypes.JSONMap `gorm:"uniqueIndex"`
}

func (*Setting) GetBool

func (s *Setting) GetBool(property string) bool

func (*Setting) Read

func (s *Setting) Read() error

func (*Setting) Upsert

func (s *Setting) Upsert() error

type User

type User struct {
	ID          uuid.UUID       `gorm:"type:uuid;primaryKey" json:"id"`
	CreatedAt   time.Time       `json:"createdAt"`
	UpdatedAt   time.Time       `json:"updatedAt"`
	DeletedAt   *gorm.DeletedAt `gorm:"index" json:"deletedAt,omitempty"`
	FirstName   string          `gorm:"not null" json:"firstName"`
	LastName    string          `gorm:"not null" json:"lastName"`
	Email       string          `gorm:"uniqueIndex;not null" json:"email"`
	Password    string          `gorm:"not null" json:"-"`
	RoleID      uint            `json:"-"`
	Role        *Role           `gorm:"constraint:OnDelete:SET NULL" json:"role,omitempty"`
	Session     *Session        `gorm:"constraint:OnDelete:SET NULL" json:"session,omitempty"`
	RawPassword string          `gorm:"-" json:"password,omitempty"`
}

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) error

func (*User) BeforeSave

func (u *User) BeforeSave(tx *gorm.DB) error

func (*User) Create

func (u *User) Create() error

func (*User) Delete

func (u *User) Delete() error

func (*User) List

func (u *User) List(flags int) ([]User, error)

func (*User) Read

func (u *User) Read(flags int) error

func (*User) Update

func (u *User) Update() error

func (*User) ValidatePassword

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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