infrastructure

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectMongoDB

func ConnectMongoDB(ctx context.Context, name string, connection string) (*mongo.Database, error)

ConnectMongoDB connects to MongoDB

Types

type MongoRepository

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

MongoRepository struct of a mongo repository

func NewMongoRepository

func NewMongoRepository(collection *mongo.Collection, target interface{}) *MongoRepository

NewMongoRepository creates a mongodb repository

func (*MongoRepository) Create

func (r *MongoRepository) Create(ctx context.Context, entity interface{}) (primitive.ObjectID, error)

Create creates an entity in the repository's collection

func (*MongoRepository) Delete

func (r *MongoRepository) Delete(ctx context.Context, ID string) error

Delete deletes the document with the specified ID in the repository's collection

func (*MongoRepository) Get

func (r *MongoRepository) Get(ctx context.Context, filter primitive.M, skip, limit *int) ([]interface{}, error)

Get gets the documents mathing the filter in the repository's collection

func (*MongoRepository) GetByID

func (r *MongoRepository) GetByID(ctx context.Context, ID string) (interface{}, error)

GetByID get the document with the specified ID in the repository's collection

func (*MongoRepository) Update

func (r *MongoRepository) Update(ctx context.Context, ID string, entity interface{}, upsert bool) error

Update updates the document with the specified ID in the repository's collection

Jump to

Keyboard shortcuts

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