storage

package
v0.0.0-...-f3973e5 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("record not found")

Functions

This section is empty.

Types

type ItemStore

type ItemStore interface {
	GetItemByID(id string) (models.Item, error)
	AddItem(item models.Item) error
	GetAllItems() ([]models.Item, error)
	AddItemStored(item models.Item) error
}

type LocationStore

type LocationStore interface {
	AddLocation(loc models.Location) error
	GetLocationByID(id string) (models.Location, error)
	GetAllLocations() ([]models.Location, error)
}

type Store

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

func NewStore

func NewStore(ctx context.Context, databaseFile string) *Store

func NewStoreWithMigrations

func NewStoreWithMigrations(ctx context.Context, databaseFile string, migrations fs.FS) (*Store, error)

func (*Store) AddItem

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

func (*Store) AddItemStored

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

func (*Store) AddLocation

func (s *Store) AddLocation(loc models.Location) error

AddLocation adds a new location to the database

Returns an error if the query fails for other reasons.

func (*Store) Connect

func (s *Store) Connect() error

func (*Store) Disconnect

func (s *Store) Disconnect() error

func (*Store) GetAllItems

func (s *Store) GetAllItems() ([]models.Item, error)

func (*Store) GetAllLocations

func (s *Store) GetAllLocations() ([]models.Location, error)

GetAllLocations returns all locations from the database

Returns an error if the query fails for other reasons.

func (*Store) GetItemByID

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

func (*Store) GetLocationByID

func (s *Store) GetLocationByID(id string) (models.Location, error)

GetLocationByID will search for a location with the given id.

Returns storage.ErrNotFound if location not found.

Returns an error if the query fails for other reasons.

Jump to

Keyboard shortcuts

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