dao

package
v0.0.0-...-eb4e5ec Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dao

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

Dao encapsulates database operations.

func NewDao

func NewDao(mongoURI, database, collection string) (*Dao, error)

NewDao constructs a data access object (Dao).

func (*Dao) AddFile

func (d *Dao) AddFile(username string, file File) error

AddFile adds given file for given user.

func (*Dao) CreateNewUser

func (d *Dao) CreateNewUser(user User) error

CreateNewUser creates a new user.

func (*Dao) GetFileInfo

func (d *Dao) GetFileInfo(username, filename string) (*File, error)

GetFileInfo returns the info of given file.

func (*Dao) GetUserFiles

func (d *Dao) GetUserFiles(username string) (*[]File, error)

GetUserFiles returns files of given user.

func (*Dao) GetUserInfo

func (d *Dao) GetUserInfo(username string) (*User, error)

GetUserInfo returns the info of given user.

func (*Dao) GetUserStrategy

func (d *Dao) GetUserStrategy(username string) (*Strategy, error)

GetUserStrategy returns the storage strategy of given user.

func (*Dao) RemoveFile

func (d *Dao) RemoveFile(username, filename string) error

RemoveFile removes the given file from database.

func (*Dao) SetUserStrategy

func (d *Dao) SetUserStrategy(username string, strategy Strategy) error

SetUserStrategy sets the storage strategy of given user.

type File

type File struct {
	Filename     string   `json:"filename"`
	Size         int64    `json:"size"`
	LastModified int64    `json:"last_modified"`
	Sites        []string `json:"sites"`
}

type Strategy

type Strategy struct {
	Sites []string `json:"sites"`
}

type User

type User struct {
	Username string
	Password string
	Role     string
	Strategy Strategy
	Files    []File
}

Jump to

Keyboard shortcuts

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