models

package
Version: v0.0.0-...-c118757 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenUUID

func GenUUID() uuid.UUID

GenUUID is used to create a new UUID easily and consistently.

Types

type Group

type Group struct {
	ID        uuid.UUID  `json:"id"`
	Name      string     `json:"name"`
	OwnerID   uuid.UUID  `json:"owner_id"`
	Members   []User     `json:"members"`
	CreatedAt types.Date `json:"created_at"`
	UpdatedAt types.Date `json:"updated_at"`
}

Group model

func NewGroup

func NewGroup(name string, owner *User) *Group

NewGroup returns a new Group model

type Image

type Image struct {
	ID          uuid.UUID  `json:"id"`
	Filename    string     `json:"filename"`
	StoragePath string     `json:"storagepath"`
	Sha256      string     `json:"sha256"`
	Size        int        `json:"size"`
	Height      int        `json:"height"`
	Width       int        `json:"width"`
	OwnerID     uuid.UUID  `json:"owner_id"`
	CreatedAt   types.Date `json:"created_at"`
	UpdatedAt   types.Date `json:"updated_at"`
}

Image structure models the same table

func NewImage

func NewImage(filename string, owner *User) *Image

NewImage creates a new Image model

func (*Image) Process

func (i *Image) Process(data []byte) error

Process processes the file and fills metadata

type ImageShare

type ImageShare struct {
	ID        uuid.UUID  `json:"id"`
	ImageID   uuid.UUID  `json:"image_id"`
	UserID    uuid.UUID  `json:"user_id"`
	Shared    bool       `json:"shared"`
	CreatedAt types.Date `json:"created_at"`
	UpdatedAt types.Date `json:"updated_at"`
}

ImageShare structure models a share

func NewImageShare

func NewImageShare(image *Image, user *User) *ImageShare

NewImageShare creates a new ImageShare struct

type Profile

type Profile struct {
	ID           uuid.UUID  `json:"id"`
	UserID       uuid.UUID  `json:"user_id"`
	BackgroundID uuid.UUID  `json:"background_id"`
	ProfileID    uuid.UUID  `json:"profile_id"`
	CreatedAt    types.Date `json:"created_at"`
	UpdatedAt    types.Date `json:"updated_at"`
}

Profile holds special profile information

func NewProfile

func NewProfile(user *User, background, profile *Image) *Profile

NewProfile returns a new profile object

type Role

type Role struct {
	ID          uuid.UUID  `json:"id"`
	Name        string     `json:"name"`
	Description string     `json:"description"`
	CreatedAt   types.Date `json:"created_at"`
	UpdatedAt   types.Date `json:"updated_at"`
}

Role is used for access control

func NewRole

func NewRole(name, description string) *Role

NewRole returns a new role model

type User

type User struct {
	ID        uuid.UUID  `json:"id"`
	Name      string     `json:"name"`
	Username  string     `json:"username"`
	Email     string     `json:"email"`
	Password  string     `json:"password"`
	Token     uuid.UUID  `json:"token"`
	CreatedAt types.Date `json:"created_at"`
	UpdatedAt types.Date `json:"updated_at"`
}

User holds the user model

func NewUser

func NewUser(name, username, email, password string) *User

NewUser returns a raw User model

func (*User) GenToken

func (u *User) GenToken()

GenToken creates a new token as a V4UUID

Jump to

Keyboard shortcuts

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