Documentation ¶
Index ¶
- func ConnectToMongoDB(uri string) (*mongo.Client, error)
- type CollectionInterface
- type RealCollection
- func (rc *RealCollection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (rc *RealCollection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func (rc *RealCollection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
- func (rc *RealCollection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (rc *RealCollection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.
Click to show internal directories.
Click to hide internal directories.