media

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The database table name for media.
	TableName = "media"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository interface {
	List(meta params.Params) (domain.MediaItems, int, error)
	Find(id int) (domain.Media, error)
	FindByName(name string) (domain.Media, error)
	FindByURL(url string) (domain.Media, string, error)
	Create(m domain.Media) (domain.Media, error)
	Update(m domain.Media) (domain.Media, error)
	Delete(id int) error
	Exists(fileName string) bool
}

Repository defines methods for media items to interact with the database.

type Store

type Store struct {
	*config.Config
}

Store defines the data layer for media.

func New

func New(cfg *config.Config) *Store

New

Creates a new media store.

func (*Store) Create

func (s *Store) Create(m domain.Media) (domain.Media, error)

Create

Returns a new media item upon creation. Returns errors.INTERNAL if the SQL query was invalid or the function could not get the newly created ID.

func (*Store) Delete

func (s *Store) Delete(id int) error

Delete

Returns nil if the category was successfully deleted. Returns errors.INTERNAL if the SQL query was invalid. Returns errors.NOTFOUND if the category was not found.

func (*Store) Exists

func (s *Store) Exists(fileName string) bool

Exists

Returns a bool indicating if the media item exists by name. Logs errors.INTERNAL if there was an error executing the query.

func (*Store) Find

func (s *Store) Find(id int) (domain.Media, error)

Find

Returns a media item by searching with the given ID. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the media item was not found by the given ID.

func (*Store) FindByName

func (s *Store) FindByName(name string) (domain.Media, error)

FindByName

Returns a media item by searching with the given name. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the media was not found by the given name.

func (*Store) FindByURL

func (s *Store) FindByURL(url string) (domain.Media, string, error)

FindByURL

Returns a media by searching with the given url. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the media item was not found by the given url.

func (*Store) List

func (s *Store) List(meta params.Params) (domain.MediaItems, int, error)

List

Returns a slice of media items with the total amount. Returns errors.INTERNAL if the SQL query was invalid. Returns errors.NOTFOUND if there are no media items available.

func (*Store) Update

func (s *Store) Update(m domain.Media) (domain.Media, error)

Update

Returns an updated media item. Returns errors.CONFLICT if the validation failed. Returns errors.INTERNAL if the SQL query was invalid or the function could not obtain the newly created ID.

Jump to

Keyboard shortcuts

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