db

package
v0.0.0-...-c17fed3 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToMongoDB

func ConnectToMongoDB(uri string) (*mongo.Client, error)

Types

type CollectionInterface

type CollectionInterface interface {
	InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
	UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
	DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
	Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
	FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
}

type RealCollection

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

RealCollection es una implementación real de CollectionInterface usando mongo.Collection.

func NewRealCollection

func NewRealCollection(collection *mongo.Collection) *RealCollection

NewRealCollection crea una nueva instancia de RealCollection.

func (*RealCollection) DeleteOne

func (rc *RealCollection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

DeleteOne elimina un documento de la colección que coincida con el filtro.

func (*RealCollection) Find

func (rc *RealCollection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)

Find busca documentos en la colección que coincidan con el filtro.

func (*RealCollection) FindOne

func (rc *RealCollection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult

FindOne busca un documento en la colección que coincida con el filtro.

func (*RealCollection) InsertOne

func (rc *RealCollection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

InsertOne inserta un documento en la colección.

func (*RealCollection) UpdateOne

func (rc *RealCollection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateOne actualiza un documento en la colección que coincida con el filtro.

Jump to

Keyboard shortcuts

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