models

package
v0.0.0-...-1edb5c9 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileDirsTableName = "filedirs"
)

FileDirsTableName is the name of the filedirs table in the db

Variables

View Source
var (
	TimeParam = map[string]bool{
		"created": true,
		"updated": true,
	}
	SkipParam = map[string]bool{
		"created": true,
		"id":      true,
	}
)

TimeParam are variables where there needs to be conversion from time.Time to a string that can be parsed in timestamptz SkipParam are params that we skip on update

Functions

func LayerInstance

func LayerInstance() *layer

LayerInstance gets the static singleton reference using double check synchronization. It returns the reference to the layer.

Types

type FileDirs

type FileDirs struct {
	ID      int64     `valid:"-" json:"id"`
	Name    string    `valid:"required" json:"name"`
	Data    string    `valid:"-" json:"data"`
	Created time.Time `valid:"-" json:"created"`
	Updated time.Time `valid:"-" json:"updated"`
	Size    int64     `valid:"-" json:"size"`
	Type    string    `valid:"-" json:"filetype"`
	Path    string    `valid:"-" json:"path"`
}

FileDirs represents a single row in the FileTable

type FileDirsTable

type FileDirsTable struct {
	// contains filtered or unexported fields
}

FileDirsTable represents the connection to the db instance

func NewFileDirsTable

func NewFileDirsTable(db *db.Db) (fileDirsTable FileDirsTable, err error)

NewFileDirsTable creates a new table in the database for files and directories. It takes a reference to an open db connection and returns the constructed table This code doesn't actually run since the database is created using the migration script.

func (*FileDirsTable) DeletePath

func (table *FileDirsTable) DeletePath(path string) (rows int64, err error)

DeletePath deletes a file/dir and everything under it

func (*FileDirsTable) GetAllPath

func (table *FileDirsTable) GetAllPath(path string, levels int) (items []*FileDirs, err error)

GetAllPath returns all entries under a directory in the FileDirs table

func (*FileDirsTable) GetPath

func (table *FileDirsTable) GetPath(path string) (item *FileDirs, err error)

GetPath returns an entry in the FileDirs table

func (*FileDirsTable) Insert

func (table *FileDirsTable) Insert(newItem *FileDirs, path string) (insertedItem *FileDirs, err error)

Insert inserts either a file or a directory into the fs

func (*FileDirsTable) Update

func (table *FileDirsTable) Update(updates *FileDirs, path string) (updatedItem *FileDirs, err error)

Update updates an item in the database This update function specifically does not update the path

func (*FileDirsTable) UpdatePath

func (table *FileDirsTable) UpdatePath(sourcePath, destPath string) (updatedItems []*FileDirs, err error)

UpdatePath moves the file at source path to be under destination folder

Jump to

Keyboard shortcuts

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