storage

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

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

Go to latest
Published: Sep 27, 2021 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// CollectionBeer identifier for JSON collection about beers
	CollectionBeer int = iota
	// CollectionReview identifier for JSON collection about reviews
	CollectionReview
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JSON

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

JSON is the data storage layered using JSON file

func NewJSON

func NewJSON(location string) (*JSON, error)

func (*JSON) FindBeer

func (s *JSON) FindBeer(criteria models.Beer) ([]*models.Beer, error)

FindBeer locate full data set based on given criteria

func (*JSON) FindBeers

func (s *JSON) FindBeers() []models.Beer

func (*JSON) FindReview

func (s *JSON) FindReview(criteria models.Review) ([]*models.Review, error)

FindReview locate full data set based on given criteria

func (*JSON) FindReviews

func (s *JSON) FindReviews() []models.Review

func (*JSON) SaveBeer

func (s *JSON) SaveBeer(beers ...models.Beer) error

SaveBeer insert new beers

func (*JSON) SaveReview

func (s *JSON) SaveReview(reviews ...models.Review) error

SaveReview insert reviews

type Memory

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

Memory data storage layered save only in memory

func (*Memory) FindBeer

func (s *Memory) FindBeer(criteria models.Beer) ([]*models.Beer, error)

FindBeer locate full data set based on given criteria

func (*Memory) FindBeers

func (s *Memory) FindBeers() []models.Beer

FindBeers return all beers

func (*Memory) FindReview

func (s *Memory) FindReview(criteria models.Review) ([]*models.Review, error)

FindReview locate full data set based on given criteria

func (*Memory) FindReviews

func (s *Memory) FindReviews() []models.Review

FindReviews return all reviews

func (*Memory) SaveBeer

func (s *Memory) SaveBeer(beers ...models.Beer) error

SaveBeer insert or update beers

func (*Memory) SaveReview

func (s *Memory) SaveReview(reviews ...models.Review) error

SaveReview insert or update reviews

Source Files

Jump to

Keyboard shortcuts

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