Documentation ¶
Overview ¶
Package mongodb is an implementation of a model.IRepository backed up by a mongodb.
Index ¶
- Constants
- func NewDefaultConfig() (*viper.Viper, error)
- type MongoDBRepository
- func (r MongoDBRepository) CreateAgreement(agreement *model.Agreement) (*model.Agreement, error)
- func (r MongoDBRepository) CreateProvider(provider *model.Provider) (*model.Provider, error)
- func (r MongoDBRepository) CreateTemplate(template *model.Template) (*model.Template, error)
- func (r MongoDBRepository) CreateViolation(v *model.Violation) (*model.Violation, error)
- func (r MongoDBRepository) DeleteAgreement(agreement *model.Agreement) error
- func (r MongoDBRepository) DeleteProvider(provider *model.Provider) error
- func (r MongoDBRepository) GetAgreement(id string) (*model.Agreement, error)
- func (r MongoDBRepository) GetAgreementsByState(states ...model.State) (model.Agreements, error)
- func (r MongoDBRepository) GetAllAgreements() (model.Agreements, error)
- func (r MongoDBRepository) GetAllProviders() (model.Providers, error)
- func (r MongoDBRepository) GetAllTemplates() (model.Templates, error)
- func (r MongoDBRepository) GetProvider(id string) (*model.Provider, error)
- func (r MongoDBRepository) GetTemplate(id string) (*model.Template, error)
- func (r MongoDBRepository) GetViolation(id string) (*model.Violation, error)
- func (r MongoDBRepository) UpdateAgreement(agreement *model.Agreement) (*model.Agreement, error)
- func (r MongoDBRepository) UpdateAgreementState(id string, newState model.State) (*model.Agreement, error)
Constants ¶
const ( // Name is the unique identifier of this repository Name string = "mongodb" )
Variables ¶
This section is empty.
Functions ¶
func NewDefaultConfig ¶
NewDefaultConfig gets a default configuration for a MongoDBRepository
Types ¶
type MongoDBRepository ¶
type MongoDBRepository struct {
// contains filtered or unexported fields
}
MongoDBRepository contains the repository persistence implementation based on MongoDB
func New ¶
func New(config *viper.Viper) (MongoDBRepository, error)
New creates a new instance of the MongoDBRepository with the database configurarion read from a configuration file
func (MongoDBRepository) CreateAgreement ¶
CreateAgreement stores a new Agreement.
error != nil on error; error is sql.ErrNoRows if the Agreement already exists
func (MongoDBRepository) CreateProvider ¶
CreateProvider stores a new provider.
error != nil on error; error is sql.ErrNoRows if the provider already exists
func (MongoDBRepository) CreateTemplate ¶ added in v0.6.0
CreateTemplate stores a new Template.
error != nil on error; error is sql.ErrNoRows if the Template already exists
func (MongoDBRepository) CreateViolation ¶
CreateViolation stores a new Violation.
error != nil on error; error is sql.ErrNoRows if the Violation already exists
func (MongoDBRepository) DeleteAgreement ¶
func (r MongoDBRepository) 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 (MongoDBRepository) DeleteProvider ¶
func (r MongoDBRepository) 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 (MongoDBRepository) GetAgreement ¶
func (r MongoDBRepository) 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 (MongoDBRepository) GetAgreementsByState ¶ added in v0.4.0
func (r MongoDBRepository) GetAgreementsByState(states ...model.State) (model.Agreements, error)
GetAgreementsByState returns the agreements that have one of the items in states.
error != nil on error;
func (MongoDBRepository) GetAllAgreements ¶
func (r MongoDBRepository) GetAllAgreements() (model.Agreements, error)
GetAllAgreements returns the list of agreements.
The list is empty when there are no agreements; error != nil on error
func (MongoDBRepository) GetAllProviders ¶
func (r MongoDBRepository) GetAllProviders() (model.Providers, error)
GetAllProviders returns the list of providers.
The list is empty when there are no providers; error != nil on error
func (MongoDBRepository) GetAllTemplates ¶ added in v0.6.0
func (r MongoDBRepository) GetAllTemplates() (model.Templates, error)
GetAllTemplates returns the list of templates.
The list is empty when there are no templates; error != nil on error
func (MongoDBRepository) GetProvider ¶
func (r MongoDBRepository) 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 (MongoDBRepository) GetTemplate ¶ added in v0.6.0
func (r MongoDBRepository) 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 (MongoDBRepository) GetViolation ¶
func (r MongoDBRepository) 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 (MongoDBRepository) UpdateAgreement ¶
UpdateAgreement updates the information of an already saved instance of an agreement
func (MongoDBRepository) UpdateAgreementState ¶ added in v0.4.0
func (r MongoDBRepository) UpdateAgreementState(id string, newState model.State) (*model.Agreement, error)
UpdateAgreementState transits the state of the agreement