storage

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInternal = errors.New("internal storage error")

Functions

This section is empty.

Types

type CardRepo

type CardRepo interface {
	Repo[value.Card]

	ListAllInDeck(ctx context.Context, deck value.Deck) ([]value.Card, error)

	FindAll(ctx context.Context, front, back string) ([]value.Card, error)
	FindAllInDeck(ctx context.Context, front, back string, deck value.Deck) ([]value.Card, error)
	FindAllByFront(ctx context.Context, front string) ([]value.Card, error)
	FindAllByFrontInDeck(ctx context.Context, front string, deck value.Deck) ([]value.Card, error)

	DeleteAllInDeck(ctx context.Context, deck value.Deck) error
}

type DeckRepo

type DeckRepo interface {
	Repo[value.Deck]

	FindByName(ctx context.Context, name string) (*value.Deck, error)
}

type Repo

type Repo[T any] interface {
	ListAll(ctx context.Context) ([]T, error)

	FindByID(ctx context.Context, id string) (*T, error)

	Save(ctx context.Context, item T) (*T, error)

	Delete(ctx context.Context, item T) error
}

type Storage

type Storage interface {
	// GetCardRepo should return stored CardRepo implementation.
	GetCardRepo() CardRepo
	// GetDeckRepo should return stored DeckRepo implementation.
	GetDeckRepo() DeckRepo
	// Close gently closes living connection to datasource(if there is some).
	Close() error
}

Storage describes a storage with living connection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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