Documentation ¶
Overview ¶
Package memrepository is a simple implementation of a model.IRepository intended for developing purposes.
Index ¶
- type MemRepository
- func (r MemRepository) CreateAgreement(agreement *model.Agreement) (*model.Agreement, error)
- func (r MemRepository) CreateProvider(provider *model.Provider) (*model.Provider, error)
- func (r MemRepository) CreateTemplate(template *model.Template) (*model.Template, error)
- func (r MemRepository) CreateViolation(v *model.Violation) (*model.Violation, error)
- func (r MemRepository) DeleteAgreement(agreement *model.Agreement) error
- func (r MemRepository) DeleteProvider(provider *model.Provider) error
- func (r MemRepository) GetAgreement(id string) (*model.Agreement, error)
- func (r MemRepository) GetAgreementsByState(states ...model.State) (model.Agreements, error)
- func (r MemRepository) GetAllAgreements() (model.Agreements, error)
- func (r MemRepository) GetAllProviders() (model.Providers, error)
- func (r MemRepository) GetAllTemplates() (model.Templates, error)
- func (r MemRepository) GetProvider(id string) (*model.Provider, error)
- func (r MemRepository) GetTemplate(id string) (*model.Template, error)
- func (r MemRepository) GetViolation(id string) (*model.Violation, error)
- func (r MemRepository) UpdateAgreement(agreement *model.Agreement) (*model.Agreement, error)
- func (r MemRepository) UpdateAgreementState(id string, newState model.State) (*model.Agreement, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemRepository ¶
type MemRepository struct {
// contains filtered or unexported fields
}
MemRepository is a repository in memory
func New ¶
func New(config *viper.Viper) (MemRepository, error)
New creates a new instance of MemRepository
func NewMemRepository ¶
func NewMemRepository(providers map[string]model.Provider, agreements map[string]model.Agreement, violations map[string]model.Violation, penalties map[string]model.Penalty, templates map[string]model.Template) MemRepository
NewMemRepository creates a MemRepository with an initial state set by the parameters
func (MemRepository) CreateAgreement ¶
CreateAgreement stores a new Agreement.
error != nil on error; error is sql.ErrNoRows if the Agreement already exists
func (MemRepository) CreateProvider ¶
CreateProvider stores a new provider.
error != nil on error; error is sql.ErrNoRows if the provider already exists
func (MemRepository) CreateTemplate ¶
CreateTemplate stores a new Template.
error != nil on error; error is sql.ErrNoRows if the Template already exists
func (MemRepository) CreateViolation ¶
CreateViolation stores a new Violation.
error != nil on error; error is sql.ErrNoRows if the Violation already exists
func (MemRepository) DeleteAgreement ¶
func (r MemRepository) DeleteAgreement(agreement *model.Agreement) error
DeleteAgreement deletes from the repository the Agreement whose id is provider.Id.
error != nil on error; error is sql.ErrNoRows if the Agreement does not exist.
func (MemRepository) DeleteProvider ¶
func (r MemRepository) DeleteProvider(provider *model.Provider) error
DeleteProvider deletes from the repository the provider whose id is provider.Id.
error != nil on error; error is sql.ErrNoRows if the provider does not exist.
func (MemRepository) GetAgreement ¶
func (r MemRepository) GetAgreement(id string) (*model.Agreement, error)
GetAgreement returns the Agreement identified by id.
error != nil on error; error is sql.ErrNoRows if the Agreement is not found
func (MemRepository) GetAgreementsByState ¶
func (r MemRepository) GetAgreementsByState(states ...model.State) (model.Agreements, error)
GetAgreementsByState returns the agreements that match any of the items in states.
error != nil on error
func (MemRepository) GetAllAgreements ¶
func (r MemRepository) GetAllAgreements() (model.Agreements, error)
GetAllAgreements returns the list of agreements.
The list is empty when there are no agreements; error != nil on error
func (MemRepository) GetAllProviders ¶
func (r MemRepository) GetAllProviders() (model.Providers, error)
GetAllProviders returns the list of providers.
The list is empty when there are no providers; error != nil on error
func (MemRepository) GetAllTemplates ¶
func (r MemRepository) GetAllTemplates() (model.Templates, error)
GetAllTemplates returns the list of templates.
The list is empty when there are no templates; error != nil on error
func (MemRepository) GetProvider ¶
func (r MemRepository) GetProvider(id string) (*model.Provider, error)
GetProvider returns the Provider identified by id.
error != nil on error; error is sql.ErrNoRows if the provider is not found
func (MemRepository) GetTemplate ¶
func (r MemRepository) GetTemplate(id string) (*model.Template, error)
GetTemplate returns the Template identified by id.
error != nil on error; error is sql.ErrNoRows if the Template is not found
func (MemRepository) GetViolation ¶
func (r MemRepository) GetViolation(id string) (*model.Violation, error)
GetViolation returns the Violation identified by id.
error != nil on error; error is sql.ErrNoRows if the Violation is not found
func (MemRepository) UpdateAgreement ¶
UpdateAgreement updates the information of an already saved instance of an agreement
func (MemRepository) UpdateAgreementState ¶
func (r MemRepository) UpdateAgreementState(id string, newState model.State) (*model.Agreement, error)
UpdateAgreementState transits the state of the agreement