classes

package
v0.0.0-...-4c1f3c0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ClassDoesNotExist = errors.New("no existing class found by that id")
)

Functions

This section is empty.

Types

type ClassRepository

type ClassRepository interface {
	// GetAll returns all of the available Class items, paginated based on the
	// passed arguments.
	GetAll(pq utils.PaginationQuery) ([]models.Class, error)

	// Get returns a single Class by its ID.
	Get(id string) (*models.Class, error)

	// Update takes a class object that has been mutated and persists it to the
	// data store, returning the modified object and possibly an error.
	Update(class *models.Class) (*models.Class, error)

	// Create takes a class object that has been populated with data and creates
	// a record for it in the data store, returning the filled record and
	// possibly an error.
	Create(class models.Class) (*models.Class, error)

	// Delete takes a class object that includes at least an ID and deletes the
	// relevant record for it in the data store.
	Delete(class models.Class) error

	// Count returns the total number of classes in the datastore.
	Count() (int, error)
}

ClassRepository defines a common interface for querying Class data

type InMemoryClassRepository

type InMemoryClassRepository struct {
	// Items is the slice of [models.Class] items stored in memory.
	Items []models.Class
}

InMemoryClassRepository implements the ClassRepository interface using an in-memory slice of models.Class items.

func NewInMemoryClassRepository

func NewInMemoryClassRepository(itemCount int) InMemoryClassRepository

NewInMemoryClassRepository creates a new instance of NewInMemoryClassRepository

func (*InMemoryClassRepository) Count

func (r *InMemoryClassRepository) Count() (int, error)

func (*InMemoryClassRepository) Create

func (r *InMemoryClassRepository) Create(class models.Class) (*models.Class, error)

func (*InMemoryClassRepository) Delete

func (r *InMemoryClassRepository) Delete(class models.Class) error

func (*InMemoryClassRepository) Get

func (*InMemoryClassRepository) GetAll

func (*InMemoryClassRepository) Update

func (r *InMemoryClassRepository) Update(class *models.Class) (*models.Class, error)

Jump to

Keyboard shortcuts

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