movies

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Routes

func Routes(root *echo.Group, ds *Datasource)

Routes creates and expose the router.

Types

type Datasource

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

Datasource manages the movies data.

func NewDatasource

func NewDatasource(db *bolt.DB) *Datasource

NewDatasource creates a new instance of movie datasource.

func (*Datasource) Fetch

func (ds *Datasource) Fetch(id string) (Movie, error)

Fetch fetches the movie by id, if not exist an error will be returned.

func (*Datasource) FetchAll

func (ds *Datasource) FetchAll() (Movies, error)

FetchAll retrieves all the movies stored.

func (*Datasource) Remove

func (ds *Datasource) Remove(id string) error

Remove removes the movie from database, if some error occurs, an error will be returned.

func (*Datasource) Store

func (ds *Datasource) Store(m Movie) (Movie, error)

Store stores the movie content into the database, if some error occurs, an error will be returned.

type Date

type Date struct {
	time.Time
}

Date it is a custom struct for masharlling and unmarshalling dates.

func (Date) MarshalJSON

func (dt Date) MarshalJSON() ([]byte, error)

MarshalJSON marshals a Date into a "Y-m-d" format.

func (*Date) UnmarshalJSON

func (dt *Date) UnmarshalJSON(value []byte) error

UnmarshalJSON unmarshals the string date into Date instance.

func (Date) Validate

func (dt Date) Validate() error

Validate validates if the date is zero.

type Movie

type Movie struct {
	ID       string `json:"id"`
	Title    string `json:"title"`
	Released Date   `json:"released"`
}

Movie represents a movie in the system.

func (Movie) Validate

func (m Movie) Validate() error

Validate validates the movie structure.

type Movies

type Movies []Movie

Movies represents a collection of movie.

Jump to

Keyboard shortcuts

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