file

package
v0.0.0-...-fdd2a27 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllFinder

type AllFinder interface {
	FindAll(context.Context) ([]*FileRecord, error)
}

type DBError

type DBError struct {
	Err error
}

func DBErrorMessage

func DBErrorMessage(message string) *DBError

func DuplicateKeyError

func DuplicateKeyError(message string) *DBError

func IndexNotCreatedError

func IndexNotCreatedError(message string) *DBError

func NewDBError

func NewDBError(err error) *DBError

func NoRowsFoundError

func NoRowsFoundError(message string) *DBError

Common DB errors

func (*DBError) Error

func (de *DBError) Error() string

type Deleter

type Deleter interface {
	Delete(context.Context, string) error
}

type FileInformationRepository

type FileInformationRepository interface {
	FindById(context.Context, string) (*FileRecord, error)
	FindAll(context.Context) ([]*FileRecord, error)
	Create(context.Context, FileRecord) (*FileRecord, error)
	Delete(context.Context, string) error
}

type FileInformationService

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

func (*FileInformationService) Delete

func (m *FileInformationService) Delete(ctx context.Context, id string) error

func (*FileInformationService) FindAll

func (m *FileInformationService) FindAll(ctx context.Context) ([]*FileRecord, error)

func (*FileInformationService) FindById

func (m *FileInformationService) FindById(ctx context.Context, id string) (*FileRecord, error)

func (*FileInformationService) Save

type FileRecord

type FileRecord struct {
	ID         uint      `json:"id"`
	Filename   string    `json:"name"`
	FileType   string    `json:"type"`
	S3Link     string    `json:"link"`
	Category   string    `json:"category"`
	UploadDate time.Time `json:"uploadDate"`
	Metadata   `json:"metadata"`
}

FileRecord is a DTO

type Finder

type Finder interface {
	FindById(context.Context, string) (*FileRecord, error)
}

type Metadata

type Metadata struct {
	Title  string `json:"title"`
	Artist string `json:"artist"`
	Album  string `json:"album"`
	Year   int    `json:"year"`
}

func GetMetadata

func GetMetadata(file multipart.File) (Metadata, error)

type PostgresStore

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

func NewPostgresStore

func NewPostgresStore(config config.FileInformationStoreConfig) (*PostgresStore, error)

func (*PostgresStore) Create

func (p *PostgresStore) Create(ctx context.Context, fileInformation FileRecord) (*FileRecord, error)

func (*PostgresStore) CreateIndexOn

func (p *PostgresStore) CreateIndexOn(name string, columns []string) error

CreateIndexOn creates an index on the list of columns given. The name provided will be

func (*PostgresStore) CreateTable

func (p *PostgresStore) CreateTable() error

func (*PostgresStore) Delete

func (p *PostgresStore) Delete(ctx context.Context, id string) error

func (*PostgresStore) FindAll

func (p *PostgresStore) FindAll(ctx context.Context) ([]*FileRecord, error)

func (*PostgresStore) FindById

func (p *PostgresStore) FindById(ctx context.Context, id string) (*FileRecord, error)

type Saver

type Saver interface {
	Save(context.Context, multipart.File) (*FileRecord, error)
}

type Storer

type Storer interface {
	Saver
	Deleter
	Finder
	AllFinder
}

Storer defines the API for interacting with NO/SQL storage

Jump to

Keyboard shortcuts

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