mongodb

package
v0.0.0-...-fff90db Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMongoDBConnection represents an error while attempting to create a connection to the
	// given MongoDB server.
	ErrMongoDBConnection = errors.New("MongoDB connection error")
	// ErrMongoDBValidation represents an error while attempting to check the existing connection
	// to the given MongoDB server.
	ErrMongoDBValidation = errors.New("MongoDB connection validation error")
)

Functions

func NewMongoClient

func NewMongoClient(url string) (*mongo.Client, error)

NewMongoClient creates a new MongoDB client.

Types

type AnalysisDB

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

AnalysisDB represents a MongoDB database, focused on the collection handling the analysis documents.

func NewMongoDBAnalysisRepository

func NewMongoDBAnalysisRepository(client *mongo.Client, dbname string) *AnalysisDB

NewMongoDBAnalysisRepository creates a repository.AnalysisRepository backed up by a MongoDB database.

func (*AnalysisDB) Add

func (adb *AnalysisDB) Add(ctx context.Context, analysis entity.AnalysisResults) error

Add transforms and stores an AnalysisResults entity into a document on the underlying MongoDB collection.

func (*AnalysisDB) Delete

func (adb *AnalysisDB) Delete(ctx context.Context, id uuid.UUID) error

Delete removes an existing Analysis from the underlying MongoDB collection.

func (*AnalysisDB) GetByProjectID

func (adb *AnalysisDB) GetByProjectID(ctx context.Context, projectID uuid.UUID) (entity.AnalysisResults, error)

GetByProjectID retrieves an existing analysis for the given Project, from the underlying MongoDB collection.

type IdentifierDB

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

IdentifierDB represents a MongoDB database, focused on the collection handling the identifiers documents.

func NewMongoDBIdentifierRepository

func NewMongoDBIdentifierRepository(client *mongo.Client, dbname string) *IdentifierDB

NewMongoDBIdentifierRepository creates a repository.IdentifierRepository backed up by a MongoDB database.

func (*IdentifierDB) Add

func (idb *IdentifierDB) Add(ctx context.Context, analysis entity.AnalysisResults, ident entity.Identifier) error

Add transforms and stores an Identifier entity into a document on the underlying MongoDB collection.

func (*IdentifierDB) DeleteAllByAnalysisID

func (idb *IdentifierDB) DeleteAllByAnalysisID(ctx context.Context, analysisID uuid.UUID) error

DeleteAllByAnalysisID removes a set of existing identifires from the underlying MongoDB collection.

func (*IdentifierDB) FindAllByAnalysisID

func (idb *IdentifierDB) FindAllByAnalysisID(ctx context.Context, analysisID uuid.UUID) ([]entity.Identifier, error)

FindAllByAnalysisID retrieves all the identifiers related to a given analysis, from the underlying MongoDB collection.

func (*IdentifierDB) FindAllByProjectAndFile

func (idb *IdentifierDB) FindAllByProjectAndFile(ctx context.Context, projectRef string, filename string) ([]entity.Identifier, error)

FindAllByProjectAndFile retrieves all the identifiers for a file related to a given project, from the underlying MongoDB collection.

type InsightDB

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

InsightDB represents a MongoDB database, focused on the collection handling the insights documents.

func NewMongoDBInsightRepository

func NewMongoDBInsightRepository(client *mongo.Client, dbname string) *InsightDB

NewMongoDBInsightRepository creates a repository.InsightRepository backed up by a MongoDB database.

func (*InsightDB) AddAll

func (idb *InsightDB) AddAll(ctx context.Context, insights []entity.Insight) error

AddAll transforms and stores a set of entity.Insight entities into documents on the underlying MongoDB collection.

func (*InsightDB) DeleteAllByAnalysisID

func (idb *InsightDB) DeleteAllByAnalysisID(ctx context.Context, analysisID uuid.UUID) error

DeleteAllByAnalysisID removes a set of existing insights from the underlying MongoDB collection.

func (*InsightDB) GetByAnalysisID

func (idb *InsightDB) GetByAnalysisID(ctx context.Context, analysisID uuid.UUID) ([]entity.Insight, error)

GetByAnalysisID finds a set of existing insights on the underlying MongoDB collection, and returns them as entity.Insight.

type ProjectDB

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

ProjectDB represents a MongoDB database, focused on the collection handling the project documents.

func NewMongoDBProjecRepository

func NewMongoDBProjecRepository(client *mongo.Client, dbname string) *ProjectDB

NewMongoDBProjecRepository creates a repository.ProjectRepository backed up by a MongoDB database.

func (*ProjectDB) Add

func (pdb *ProjectDB) Add(ctx context.Context, project entity.Project) error

Add transforms and stores a Project entity into a document on the underlying MongoDB collection.

func (*ProjectDB) Delete

func (pdb *ProjectDB) Delete(ctx context.Context, projectID uuid.UUID) error

Delete removes an existing Project from the underlying MongoDB collection.

func (*ProjectDB) Get

func (pdb *ProjectDB) Get(ctx context.Context, ID uuid.UUID) (entity.Project, error)

Get finds an existing Project by ID.

func (*ProjectDB) GetByReference

func (pdb *ProjectDB) GetByReference(ctx context.Context, projectRef string) (entity.Project, error)

GetByReference finds an existing Project using the given reference as filter.

Jump to

Keyboard shortcuts

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