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