mongo

package
v0.0.0-...-481f9f6 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mongo

type Mongo struct {
	*mongo.Client
	Database *mongo.Database
	Logger   *slog.Logger
	// contains filtered or unexported fields
}

Mongo holds necessary fields and mongo Database session to connect

func GetDbConnection

func GetDbConnection() *Mongo

func InitMongo

func InitMongo(cl *mongo.Client, dbName string, hook in.Hook) *Mongo

func (*Mongo) Aggregate

func (d *Mongo) Aggregate(ctx context.Context, col string, q []interface{}, v interface{}) error

Aggregate runs aggregation q on docs and store the result on v

func (*Mongo) AggregateWithDiskUse

func (d *Mongo) AggregateWithDiskUse(ctx context.Context, col string, q []interface{}, v interface{}) error

func (*Mongo) BulkUpdate

func (d *Mongo) BulkUpdate(ctx context.Context, col string, models []mongo.WriteModel) error

func (*Mongo) Count

func (d *Mongo) Count(ctx context.Context, col string, q interface{}) (int64, error)

func (*Mongo) DeleteMany

func (d *Mongo) DeleteMany(ctx context.Context, col string, filter interface{}) error

func (*Mongo) Disconnect

func (d *Mongo) Disconnect(ctx context.Context) error

func (*Mongo) Distinct

func (d *Mongo) Distinct(ctx context.Context, col, field string, q interface{}, v interface{}) error

func (*Mongo) DropIndices

func (d *Mongo) DropIndices(ctx context.Context, col string, index []db.Index) error

DropIndices drops indices from collection col

func (*Mongo) EnsureIndices

func (d *Mongo) EnsureIndices(ctx context.Context, col string, index []db.Index) error

EnsureIndices creates indices for collection col

func (*Mongo) FindOne

func (d *Mongo) FindOne(ctx context.Context, col string, q interface{}, v interface{}, sort ...interface{}) error

FindOne finds a doc by query

func (*Mongo) Insert

func (d *Mongo) Insert(ctx context.Context, col string, doc interface{}) error

Insert inserts doc into collection

func (*Mongo) InsertMany

func (d *Mongo) InsertMany(ctx context.Context, col string, docs []interface{}) error

func (*Mongo) List

func (d *Mongo) List(ctx context.Context, col string, filter interface{}, skip, limit int64, v interface{}, sort ...interface{}) error

List finds list of docs that matches query with skip and limit

func (*Mongo) PartialUpdateMany

func (d *Mongo) PartialUpdateMany(ctx context.Context, col string, filter interface{}, data interface{}) error

func (*Mongo) PartialUpdateManyByQuery

func (d *Mongo) PartialUpdateManyByQuery(ctx context.Context, col string, filter interface{}, query db.UnorderedDbQuery) error

func (*Mongo) Ping

func (d *Mongo) Ping(ctx context.Context) error

func (*Mongo) Update

func (d *Mongo) Update(ctx context.Context, col string, filter interface{}, data interface{}) error

Jump to

Keyboard shortcuts

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