storage

package
v0.0.0-...-95b4fb8 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 6 Imported by: 31

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