storage

package
v0.0.0-...-ac55ef5 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Admin

func Admin(p *UserData) boolean.Wrapper

Types

type File

type File struct {
	ID       int          `json:"id" db:"id"`
	UserID   int          `json:"user_id" db:"user_id"`
	Metadata FileMetadata `json:"metadata"`
	Status   string       `json:"status" db:"status"`
	Data     []byte       `json:"data" db:"data"`
}

type FileMetadata

type FileMetadata struct {
	Name      string `json:"name" db:"filename"`
	Extension string `json:"extension" db:"extension"`
	Size      int    `json:"size" db:"filesize"`
}

type Storage

type Storage struct {
	DB *sqlx.DB
}

func InitDatabase

func InitDatabase(config *config.Config) (*Storage, error)

func (*Storage) AddFile

func (s *Storage) AddFile(f *File) error

func (*Storage) AddFileTx

func (s *Storage) AddFileTx(tx *sqlx.Tx, f *File) error

func (*Storage) CheckExistence

func (s *Storage) CheckExistence(username string) (bool, error)

func (*Storage) CloseDatabase

func (s *Storage) CloseDatabase() error

func (*Storage) DeleteAllFiles

func (s *Storage) DeleteAllFiles(userID int) error

func (*Storage) DeleteFile

func (s *Storage) DeleteFile(f *File) error

func (*Storage) DeleteUser

func (s *Storage) DeleteUser(username string) error

func (*Storage) GetAllFiles

func (s *Storage) GetAllFiles(userID int) ([]File, error)

func (*Storage) GetAllUsers

func (s *Storage) GetAllUsers() ([]UserData, error)

func (*Storage) GetByUsername

func (s *Storage) GetByUsername(username string) (UserData, error)

func (*Storage) GetFile

func (s *Storage) GetFile(userID int, filename string) (*File, error)

func (*Storage) Query

func (s *Storage) Query(query string) (*sql.Rows, error)

func (*Storage) SaveNewUser

func (s *Storage) SaveNewUser(u *UserData) error

func (*Storage) UpdateFile

func (s *Storage) UpdateFile(f *File) error

type UserData

type UserData struct {
	UserID   int    `db:"id" json:"id"`
	Username string `db:"username" json:"username"`
	Email    string `db:"email" json:"email"`
	Password string `db:"password" json:"password"`
	Protocol string `db:"hashprotocol" json:"hashprotocol"`
	Admin    int    `db:"admin" json:"admin"`
}

Jump to

Keyboard shortcuts

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