Documentation
¶
Index ¶
- Variables
- type InMemoryTeacherRepository
- func (r *InMemoryTeacherRepository) Count() (int, error)
- func (r *InMemoryTeacherRepository) Create(teacher models.Teacher) (*models.Teacher, error)
- func (r *InMemoryTeacherRepository) Delete(teacher models.Teacher) error
- func (r *InMemoryTeacherRepository) Get(id string) (*models.Teacher, error)
- func (r *InMemoryTeacherRepository) GetAll(pq utils.PaginationQuery) ([]models.Teacher, error)
- func (r *InMemoryTeacherRepository) GetByEmail(email string) (*models.Teacher, error)
- func (r *InMemoryTeacherRepository) Update(teacher *models.Teacher) (*models.Teacher, error)
- type TeacherRepository
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) Delete ¶
func (r *InMemoryTeacherRepository) Delete(teacher models.Teacher) error
func (*InMemoryTeacherRepository) Get ¶
func (r *InMemoryTeacherRepository) Get(id string) (*models.Teacher, error)
func (*InMemoryTeacherRepository) GetAll ¶
func (r *InMemoryTeacherRepository) GetAll(pq utils.PaginationQuery) ([]models.Teacher, error)
func (*InMemoryTeacherRepository) GetByEmail ¶
func (r *InMemoryTeacherRepository) GetByEmail(email string) (*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
Click to show internal directories.
Click to hide internal directories.