repository

package
v0.0.0-...-3dd14bf Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

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

type Type

type Type uint

Type defines which repository be used

const (
	// NoSQL defines an NoSQL storage oriented for documents like MongoDB
	NoSQL Type = iota
)

Supported values for Type

Jump to

Keyboard shortcuts

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