teachers

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type InMemoryTeacherRepository

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

InMemoryTeacherRepository implements the TeacherRepository interface using an in-memory slice of models.Teacher items.

func NewInMemoryTeacherRepository

func NewInMemoryTeacherRepository(itemCount int) InMemoryTeacherRepository

NewInMemoryTeacherRepository creates a new instance of NewInMemoryTeacherRepository

func (*InMemoryTeacherRepository) Count

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

func (*InMemoryTeacherRepository) Create

func (*InMemoryTeacherRepository) Delete

func (r *InMemoryTeacherRepository) Delete(teacher models.Teacher) error

func (*InMemoryTeacherRepository) Get

func (*InMemoryTeacherRepository) GetAll

func (*InMemoryTeacherRepository) GetByEmail

func (r *InMemoryTeacherRepository) GetByEmail(email string) (*models.Teacher, error)

func (*InMemoryTeacherRepository) Update

func (r *InMemoryTeacherRepository) Update(teacher *models.Teacher) (*models.Teacher, error)

type TeacherRepository

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

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

	// Get returns a single teacher by its email.
	GetByEmail(email string) (*models.Teacher, error)

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

	// Create takes a teacher 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(teacher models.Teacher) (*models.Teacher, error)

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

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

TeacherRepository defines a common interface for querying Teacher data

Jump to

Keyboard shortcuts

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