mongodb

package
v0.0.0-...-1e95ff8 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectionString

func ConnectionString() (string, error)

ConnectionString creates the connection string with the full URI for a Mongos.db instance.

Types

type Service

type Service struct {
	Client *mongo.Client
	DB     *mongo.Database
}

Service provides the functionality to use

func NewService

func NewService() *Service

NewService creates a new service providing a Mongos.db connection

func (*Service) Connect

func (s *Service) Connect(ctx context.Context, databaseName string) error

Connect establishes a connection to a MongoDB instance

func (*Service) DeleteOne

func (s *Service) DeleteOne(ctx context.Context, collection string, objectID primitive.ObjectID) error

DeleteOne deletes a document in a collection.

func (*Service) Disconnect

func (s *Service) Disconnect(ctx context.Context) error

Disconnect removes a connection to a MongoDB instance

func (*Service) Find

func (s *Service) Find(ctx context.Context, collection string, filter bson.M, vs any, ops *options.FindOptions) error

Find finds many documents in a collection.

func (*Service) FindOne

func (s *Service) FindOne(ctx context.Context, collection string, filter bson.M, v any) error

FindOne finds a documents in a collection.

func (*Service) FindOneByID

func (s *Service) FindOneByID(ctx context.Context, collection string, objectID primitive.ObjectID, v any) error

FindOneByID finds a documents with a specific ID in a collection.

func (*Service) InsertOne

func (s *Service) InsertOne(ctx context.Context, collection string, v any) error

InsertOne inserts a document into a collection.

func (*Service) UpdateOne

func (s *Service) UpdateOne(ctx context.Context, collection string, objectID primitive.ObjectID, v any) error

UpdateOne updates a document in a collection.

Jump to

Keyboard shortcuts

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