models

package
v0.0.0-...-aa5bd6b Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStorage

func NewStorage(storageType StorageType) error

Types

type Beer

type Beer struct {
	ID        int       `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 properties of a beer

type Review

type Review struct {
	ID        int       `json:"id"`
	BeerID    int       `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 properties of a beer review

type Storage

type Storage interface {
	SaveBeer(...Beer) error
	SaveReview(...Review) error
	FindBeer(Beer) ([]*Beer, error)
	FindReview(Review) ([]*Review, error)
	FindBeers() []Beer
	FindReviews() []Review
}

Storage represents all possible actions available to deal with data

var DB Storage

DB is an interface to interact with data on multiple layered of data storage

type StorageType

type StorageType int

StorageType defines available storage types

const (
	// JSON will store data in JSON files saved on disk
	JSON StorageType = iota
	// Memory will store data in memory
	Memory
)

Jump to

Keyboard shortcuts

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