Documentation ¶
Overview ¶
Package repository contains everything related to storage
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMD ¶
func NewMD(config Configuration) *mongo.Database
NewMD works same that function NewMongoDatabase but, it does not return an error instead it panics
func NewMongoDatabase ¶
func NewMongoDatabase(config Configuration) (mongoDatabase *mongo.Database, err error)
NewMongoDatabase establish connection with a MongoDB database using the Configuration passed as parameter
Types ¶
type Configuration ¶
type Configuration struct { // Type defines the type of repository to which you want to establish a connection Type Host string Port int Database string User string Password string // Secure defines options like +srv in MongoDB and SSL in Postgresql Secure bool }
Configuration settings used to make a repository connection
func (Configuration) String ¶
func (c Configuration) String() string
String build and returns a URI used to establish a connection to any repository defined by the Type embbed in the Configuration structure
Supported types: NoSQL
type SurveyFinder ¶
type SurveyFinder interface { // FindSurvey search survey by id FindSurvey(string) (model.Survey, error) }
SurveyFinder defines the survey finder
type SurveyStorageNoSQL ¶
type SurveyStorageNoSQL struct {
*mongo.Collection
}
SurveyStorageNoSQL implementation of SurveyFinder that search a survey in a NoSQL storage oriented to documents
func (SurveyStorageNoSQL) FindSurvey ¶
func (s SurveyStorageNoSQL) FindSurvey(surveyId string) (survey model.Survey, err error)
FindSurvey works the same that FindSurveyContext but uses as default context the context.TODO()
func (SurveyStorageNoSQL) FindSurveyContext ¶
func (s SurveyStorageNoSQL) FindSurveyContext(ctx context.Context, surveyId string) (survey model.Survey, err error)
FindSurveyContext search a survey in an MongoDB collection using the surveyId passed as paramenter and the search is canceled if the context is canceled