store

package
v0.0.0-...-2c854d4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrQuizAlreadyPresent

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

func (*ErrQuizAlreadyPresent) Error

func (e *ErrQuizAlreadyPresent) Error() string

type ExamStore

type ExamStore = Store[*models.Exam]

type FilterStore

type FilterStore[T Storable] struct {
	*Store[T]
}

func NewFilterStore

func NewFilterStore[T Storable]() *FilterStore[T]

func (*FilterStore[T]) Filter

func (fs *FilterStore[T]) Filter(slice []T, f func(T) bool) []T

type ParticipantStore

type ParticipantStore struct {
	*FilterStore[*models.Participant]
}

func NewParticipantStore

func NewParticipantStore() *ParticipantStore

func (*ParticipantStore) ImportCSV

func (s *ParticipantStore) ImportCSV(path string) ([]*models.Participant, error)

type QuizStore

type QuizStore struct {
	// Memory store for quizzes. It satisfies FilterStorer
	// interface.
	*FilterStore[*models.Quiz]
	// contains filtered or unexported fields
}

func NewQuizStore

func NewQuizStore() *QuizStore

func (*QuizStore) Create

func (s *QuizStore) Create(quiz *models.Quiz) (*models.Quiz, error)

func (*QuizStore) Update

func (s *QuizStore) Update(quiz *models.Quiz, id string) (*models.Quiz, error)

type ResponseStore

type ResponseStore = Store[*models.Response]

type SessionStore

type SessionStore = Store[*models.Session]

type Storable

type Storable interface {
	GetHash() string

	GetID() string
	SetID(string)

	SetCreatedAt(t time.Time)
	SetUpdatedAt(t time.Time)
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
}

type Store

type Store[T Storable] struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore[T Storable]() *Store[T]

func (*Store[T]) Create

func (s *Store[T]) Create(entity T) (T, error)

func (*Store[T]) Delete

func (s *Store[T]) Delete(id string) (T, error)

func (*Store[T]) Json

func (s *Store[T]) Json() ([]byte, error)

func (*Store[T]) Read

func (s *Store[T]) Read(id string) (T, error)

func (*Store[T]) ReadAll

func (s *Store[T]) ReadAll() []T

func (*Store[T]) Update

func (s *Store[T]) Update(entity T, id string) (T, error)

type Storer

type Storer[T Storable] interface {
	Create(T) (T, error)
	ReadAll() []T
	Read(string) (T, error)
	Update(T, string) (T, error)
	Delete(string) (T, error)
	Json() ([]byte, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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