models

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func NewRememberToken added in v1.1.0

func NewRememberToken() (string, error)

Types

type File

type File struct {
	ID          string    `json:"id,omitempty"`
	FolderID    string    `json:"folder_id,omitempty"`
	MD5         string    `json:"md5,omitempty"`
	Name        string    `json:"name,omitempty"`
	Size        int64     `json:"size,omitempty"`
	ContentType string    `json:"content_type,omitempty"`
	Downloads   int64     `json:"downloads,omitempty"`
	CreatedAt   time.Time `json:"created_at,omitempty"`
	UpdatedAt   time.Time `json:"updated_at,omitempty"`
	// relations (can be empty)
	Folder *Folder `json:"folder,omitempty"`
}

func (*File) Fake added in v1.1.1

func (f *File) Fake(faker *gofakeit.Faker) (any, error)

func (*File) Validate

func (f *File) Validate() error

type Folder

type Folder struct {
	ID        string    `json:"id,omitempty"`
	SpaceID   string    `json:"space_id,omitempty"`
	Name      string    `json:"name,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	ExpiresAt time.Time `json:"expires_at,omitempty"`
	// relations (can be empty)
	Space *Space  `json:"space,omitempty"`
	Files []*File `json:"files,omitempty"`
}

func (*Folder) Fake added in v1.1.1

func (f *Folder) Fake(faker *gofakeit.Faker) (any, error)

func (*Folder) Slug

func (f *Folder) Slug() string

func (*Folder) TotalDownloads added in v1.1.0

func (f *Folder) TotalDownloads() (n int64)

func (*Folder) TotalSize added in v1.1.0

func (f *Folder) TotalSize() (n int64)

func (*Folder) Validate

func (f *Folder) Validate() error

type Permissions

type Permissions struct {
	Admins []string
}

func (*Permissions) IsAdmin

func (p *Permissions) IsAdmin(user *User) bool

func (*Permissions) IsSpaceAdmin

func (p *Permissions) IsSpaceAdmin(user *User, space *Space) bool

type Space

type Space struct {
	ID        string    `json:"id,omitempty"`
	Name      string    `json:"name,omitempty"`
	Admins    []string  `json:"admins,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	// relations (can be empty)
	Folders []*Folder `json:"folders,omitempty"`
}

func (*Space) Fake added in v1.1.1

func (s *Space) Fake(faker *gofakeit.Faker) (any, error)

func (*Space) Validate

func (s *Space) Validate() error

type User

type User struct {
	ID            string    `json:"id,omitempty"`
	Username      string    `json:"username,omitempty"`
	Name          string    `json:"name,omitempty"`
	Email         string    `json:"email,omitempty"`
	RememberToken string    `json:"remember_token,omitempty"`
	CreatedAt     time.Time `json:"created_at,omitempty"`
	UpdatedAt     time.Time `json:"updated_at,omitempty"`
}

func (*User) Fake added in v1.1.1

func (u *User) Fake(faker *gofakeit.Faker) (any, error)

func (*User) Validate added in v1.1.0

func (u *User) Validate() error

Jump to

Keyboard shortcuts

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