storage

package
v2.4.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: MIT Imports: 6 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChocolateStorage

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

ChocolateStorage stores all of the tasty chocolate, needs to be injected into User and Chocolate Resource. In the real world, you would use a database for that.

func NewChocolateStorage

func NewChocolateStorage() *ChocolateStorage

NewChocolateStorage initializes the storage

func (*ChocolateStorage) Delete

func (s *ChocolateStorage) Delete(id string) error

Delete one :(

func (ChocolateStorage) GetAll

func (s ChocolateStorage) GetAll() []model.Chocolate

GetAll of the chocolate

func (ChocolateStorage) GetOne

func (s ChocolateStorage) GetOne(id string) (model.Chocolate, error)

GetOne tasty chocolate

func (*ChocolateStorage) Insert

func (s *ChocolateStorage) Insert(c model.Chocolate) string

Insert a fresh one

func (*ChocolateStorage) Update

func (s *ChocolateStorage) Update(c model.Chocolate) error

Update updates an existing chocolate

type UserStorage

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

UserStorage stores all users

func NewUserStorage

func NewUserStorage() *UserStorage

NewUserStorage initializes the storage

func (*UserStorage) Delete

func (s *UserStorage) Delete(id string) error

Delete one :(

func (UserStorage) GetAll

func (s UserStorage) GetAll() map[string]*model.User

GetAll returns the user map (because we need the ID as key too)

func (UserStorage) GetOne

func (s UserStorage) GetOne(id string) (model.User, error)

GetOne user

func (*UserStorage) Insert

func (s *UserStorage) Insert(c model.User) string

Insert a user

func (*UserStorage) Update

func (s *UserStorage) Update(c model.User) error

Update a user

Jump to

Keyboard shortcuts

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