models

package
v0.0.0-...-b5ea6c6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2019 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PandaFile

type PandaFile struct {
	ID            string `gorm:"type:uuid;primary_key:true"`
	FileName      string `gorm:"size:255"`
	FileType      string `gorm:"size:30"`
	FileSize      int64
	FileURL       string    `gorm:"size:255"`
	Tags          []*Tag    `gorm:"many2many:panda_tags;association_foreignkey:tag"`
	UploaderEmail string    `gorm:"index;not null"`
	Uploader      *User     `gorm:"foreignkey:UserEmail"`
	CreatedAt     time.Time `gorm:"index"`
	UpdatedAt     time.Time
	DeletedAt     *time.Time
}

PandaFile represents an uploaded file that has a panda in it

func (*PandaFile) BeforeCreate

func (file *PandaFile) BeforeCreate(scope *gorm.Scope) error

BeforeCreate makes sure an ID is set for each panda file

type Tag

type Tag struct {
	Tag       string       `gorm:"size:255;primary_key:true"`
	Files     []*PandaFile `gorm:"many2many:panda_tags;foreignkey:tag"`
	CreatedAt time.Time
}

Tag is a simple string attached to a file

type User

type User struct {
	Email             string    `gorm:"size:255;primary_key:true"`
	Password          string    `gorm:"-"`
	EncryptedPassword []byte    `gorm:"size:255" json:"-"`
	CreatedAt         time.Time `gorm:"index"`
	UpdatedAt         time.Time
	DeletedAt         *time.Time
}

User is logged in user

func (*User) BeforeSave

func (u *User) BeforeSave() (err error)

BeforeSave encrypts the User's password before saving it

func (*User) ValidatePassword

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

ValidatePassword will return true if the password param is correct

Jump to

Keyboard shortcuts

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