gost

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// STATUSWELL mean gost can be show
	STATUSWELL = 1 + iota
	// STATUSDELETEDBYUSER mean gost is already deleted by user
	STATUSDELETEDBYUSER
	// STATUSDELETEDBYSYSTEM mean gost is already deleted by system
	STATUSDELETEDBYSYSTEM
)

Variables

View Source
var (

	// MaxFilesCount is max files count allowed
	MaxFilesCount = 10
)

Functions

This section is empty.

Types

type File

type File struct {
	// ID is uuid of file
	ID string `json:"id"`
	// Filename is the file name
	Filename string `json:"filename"`
	// Content is file content
	Content string `json:"content"`
}

File is gost file struct

type Gost

type Gost struct {
	// ID is gost uuid
	ID string `json:"id"`
	// Public is if the gost is public
	Public bool `json:"public"`
	// Description is gost description message
	Description string `json:"description"`
	// Version is gost version
	Version int `json:"version"`
	// Files is files contained by gost
	Files []*File `bson:"filesArray" json:"files"`
	// CreatedAt is gost created time
	CreatedAt string `json:"created_at"`
	// User is gost owner user
	User user.User `json:"user"`
	// Status is gost status
	Status int `json:"-"`
}

Gost is struct for gost

func NewDefaultGost

func NewDefaultGost(description string, files []*File, user user.User) *Gost

NewDefaultGost create gost with some default fields

func NewGost

func NewGost(description string, files []*File, user user.User, version int, public bool) *Gost

NewGost is gost contructor

func (*Gost) Create

func (g *Gost) Create() error

Create method store gost to db

func (*Gost) FindFile

func (g *Gost) FindFile(fileId string) *File

FindFile find file from gost by file uuid

func (*Gost) GetGostById

func (g *Gost) GetGostById(id string) error

GetGostById find a gost from db by id

func (*Gost) GetGostsByUsername

func (g *Gost) GetGostsByUsername(username string) ([]Gost, error)

GetGostsByUsername find gosts from db by author name

func (*Gost) IgnoreEmpty added in v0.2.6

func (g *Gost) IgnoreEmpty()

IgnoreEmpty will ignore empty file

func (*Gost) Remove

func (g *Gost) Remove(isUser bool) error

Remove method soft delete a gost

func (*Gost) Validate

func (g *Gost) Validate() bool

Validate make sure if the gost is validate

func (*Gost) WithUser

func (g *Gost) WithUser(user user.User)

WithUser add author for gost and some init fields

Jump to

Keyboard shortcuts

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