mongodb

package
v0.0.0-...-4a5832f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package mongodb is an implementation of a model.IRepository backed up by a mongodb.

Index

Constants

View Source
const (
	// Name is the unique identifier of this repository
	Name string = "mongodb"
)

Variables

This section is empty.

Functions

func NewDefaultConfig

func NewDefaultConfig() (*viper.Viper, error)

NewDefaultConfig gets a default configuration for a Repository

Types

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository contains the repository persistence implementation based on MongoDB

func New

func New(config *viper.Viper) (Repository, error)

New creates a new instance of the Repository with the database configurarion read from a configuration file

func (Repository) CreateAgreement

func (r Repository) CreateAgreement(agreement *model.Agreement) (*model.Agreement, error)

CreateAgreement stores a new Agreement.

error != nil on error; error is sql.ErrNoRows if the Agreement already exists

func (Repository) CreateProvider

func (r Repository) CreateProvider(provider *model.Provider) (*model.Provider, error)

CreateProvider stores a new provider.

error != nil on error; error is sql.ErrNoRows if the provider already exists

func (Repository) CreateTemplate

func (r Repository) CreateTemplate(template *model.Template) (*model.Template, error)

CreateTemplate stores a new Template.

error != nil on error; error is sql.ErrNoRows if the Template already exists

func (Repository) CreateViolation

func (r Repository) CreateViolation(v *model.Violation) (*model.Violation, error)

CreateViolation stores a new Violation.

error != nil on error; error is sql.ErrNoRows if the Violation already exists

func (Repository) DeleteAgreement

func (r Repository) 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 (Repository) DeleteProvider

func (r Repository) 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 (Repository) GetAgreement

func (r Repository) 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 (Repository) GetAgreementsByState

func (r Repository) GetAgreementsByState(states ...model.State) (model.Agreements, error)

GetAgreementsByState returns the agreements that have one of the items in states.

error != nil on error;

func (Repository) GetAllAgreements

func (r Repository) GetAllAgreements() (model.Agreements, error)

GetAllAgreements returns the list of agreements.

The list is empty when there are no agreements; error != nil on error

func (Repository) GetAllProviders

func (r Repository) GetAllProviders() (model.Providers, error)

GetAllProviders returns the list of providers.

The list is empty when there are no providers; error != nil on error

func (Repository) GetAllTemplates

func (r Repository) GetAllTemplates() (model.Templates, error)

GetAllTemplates returns the list of templates.

The list is empty when there are no templates; error != nil on error

func (Repository) GetProvider

func (r Repository) 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 (Repository) GetTemplate

func (r Repository) 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 (Repository) GetViolation

func (r Repository) 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 (Repository) UpdateAgreement

func (r Repository) UpdateAgreement(agreement *model.Agreement) (*model.Agreement, error)

UpdateAgreement updates the information of an already saved instance of an agreement

func (Repository) UpdateAgreementState

func (r Repository) UpdateAgreementState(id string, newState model.State) (*model.Agreement, error)

UpdateAgreementState transits the state of the agreement

Jump to

Keyboard shortcuts

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