storage

package
v0.0.0-...-be8e022 Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrItemNotFound = fmt.Errorf("item is not found")
)

Functions

This section is empty.

Types

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(mockN int) *Store

New initialize a new storage. Params:

mockN parameter indicates how many mocked data need to generate.

func (*Store) Create

func (s *Store) Create(item *models.Item) error

Create stores a new Item into the storage. It assigns a new ID to item.

func (*Store) Edit

func (s *Store) Edit(item *models.Item) error

Edit makes an edition of the Item in the storage. Returns ErrItemNotFound if Item was not find.

func (*Store) Item

func (s *Store) Item(id int) (*models.Item, error)

Item fetches the Item by its' ID from the storage. Returns ErrItemNotFound if Item was not find.

func (*Store) Len

func (s *Store) Len() int

Len returns amount of Items in the storage.

func (*Store) List

func (s *Store) List(pageNum, pageSize int) ([]models.Item, error)

List returns the list of Items from the storage and error if was occurred.

Jump to

Keyboard shortcuts

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