database

package
v0.0.0-...-f04b571 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFileAlreadyExists = errors.New("file already exists in storage")
	ErrFilesNotFound     = errors.New("couldn't find files")
)
View Source
var ErrCouldNotDeleteFile = errors.New("could not delete file")

Functions

func InsertFile

func InsertFile(ctx context.Context, tx *sqlx.Tx, path string) error

func RenameLabel

func RenameLabel(ctx context.Context, tx *sqlx.Tx, oldName string, newName string) error

func UpsertLabel

func UpsertLabel(ctx context.Context, tx *sqlx.Tx, name string, color string) error

func WithDatabase

func WithDatabase(ctx context.Context, db *DB) context.Context

Types

type DB

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

func FromContext

func FromContext(ctx context.Context) (*DB, error)

func New

func New(ctx context.Context) (*DB, error)
func (m *DB) AddFilesAndLinks(ctx context.Context, filepaths []string, labelNames []string) error

func (*DB) AddLabel

func (m *DB) AddLabel(ctx context.Context, name string, color string) (*Label, error)

func (*DB) Close

func (m *DB) Close() error

func (*DB) DeleteFiles

func (m *DB) DeleteFiles(ctx context.Context, paths []string) error

func (*DB) DeleteLabel

func (m *DB) DeleteLabel(ctx context.Context, name string) error

func (*DB) GetAllLabels

func (m *DB) GetAllLabels() ([]Label, error)

func (*DB) GetFileLabels

func (m *DB) GetFileLabels(path string) ([]Label, error)

func (*DB) GetFiles

func (m *DB) GetFiles(keywords []string) ([]File, error)

func (*DB) GetFilesByLabels

func (m *DB) GetFilesByLabels(labels []string) ([]File, error)

func (*DB) GetFilesFiltered

func (m *DB) GetFilesFiltered(pattern string, pathPrefix string) ([]File, error)

func (*DB) GetFilesFilteredWithLabels

func (m *DB) GetFilesFilteredWithLabels(labels []string, pattern string, pathPrefix string) ([]File, error)

func (*DB) GetSimilarLabel

func (m *DB) GetSimilarLabel(name string) *Label

func (*DB) LabelExists

func (m *DB) LabelExists(name string) bool

func (*DB) UpdateLabel

func (m *DB) UpdateLabel(ctx context.Context, name string, newName string, newColor string) error

type File

type File struct {
	Id      int64  `db:"id"`
	Path    string `db:"path"`
	Deleted bool
}

type Label

type Label struct {
	Id    int64  `db:"id"`
	Name  string `db:"name"`
	Color string `db:"color"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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