Version: v0.0.0-...-bc4fcfc Latest Latest

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 11 Imported by: 0




View Source
const (

	// CollectionBeer identifier for the JSON collection of beers
	CollectionBeer = "beers"
	// CollectionReview identifier for the JSON collection of reviews
	CollectionReview = "reviews"


This section is empty.


This section is empty.


type Beer

type Beer struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Brewery   string    `json:"brewery"`
	Abv       float32   `json:"abv"`
	ShortDesc string    `json:"short_description"`
	Created   time.Time `json:"created"`

Beer defines the storage form of a beer

type Review

type Review struct {
	ID        string    `json:"id"`
	BeerID    string    `json:"beer_id"`
	FirstName string    `json:"first_name"`
	LastName  string    `json:"last_name"`
	Score     int       `json:"score"`
	Text      string    `json:"text"`
	Created   time.Time `json:"created"`

Review defines the storage form of a beer review

type Storage

type Storage struct {
	// contains filtered or unexported fields

Storage stores beer data in JSON files

func NewStorage

func NewStorage() (*Storage, error)

NewStorage returns a new JSON storage

func (*Storage) AddBeer

func (s *Storage) AddBeer(b adding.Beer) error

AddBeer saves the given beer to the repository

func (*Storage) AddReview

func (s *Storage) AddReview(r reviewing.Review) error

AddReview saves the given review in the repository

func (*Storage) GetAllBeers

func (s *Storage) GetAllBeers() []listing.Beer

GetAll returns all beers

func (*Storage) GetAllReviews

func (s *Storage) GetAllReviews(beerID string) []listing.Review

GetAll returns all reviews for a given beer

func (*Storage) GetBeer

func (s *Storage) GetBeer(id string) (listing.Beer, error)

Get returns a beer with the specified ID

Jump to

Keyboard shortcuts

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