mongo

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	URI() string
	Close(context.Context) error
	Checker(context.Context, *healthcheck.CheckState) error
	Connection() *mongodriver.MongoConnection
	Collection(string) *mongodriver.Collection
}

type Mongo

type Mongo struct {
	mongodriver.MongoDriverConfig
	// contains filtered or unexported fields
}

Mongo represents a simplistic MongoDB configuration.

func New

func New(cfg config.MongoConfig) (m *Mongo, err error)

func (*Mongo) Checker

func (m *Mongo) Checker(ctx context.Context, state *healthcheck.CheckState) error

Checker is called by the healthcheck library to health the health state of this mongoDB instance

func (*Mongo) Close

func (m *Mongo) Close(ctx context.Context) error

Close represents mongo session closing within the context deadline

func (*Mongo) Collection

func (m *Mongo) Collection(wellKnownName string) *mongodriver.Collection

func (*Mongo) Connection

func (m *Mongo) Connection() *mongodriver.MongoConnection

func (*Mongo) URI

func (m *Mongo) URI() string

type MongoCollection

type MongoCollection interface {
	Must() *mongodb.Must
	Distinct(ctx context.Context, fieldName string, filter interface{}) ([]interface{}, error)
	Count(ctx context.Context, filter interface{}, opts ...mongodb.FindOption) (int, error)
	Find(ctx context.Context, filter interface{}, results interface{}, opts ...mongodb.FindOption) (int, error)
	FindCursor(ctx context.Context, filter interface{}, opts ...mongodb.FindOption) (mongodb.Cursor, error)
	FindOne(ctx context.Context, filter interface{}, result interface{}, opts ...mongodb.FindOption) error
	Insert(ctx context.Context, document interface{}) (*mongodb.CollectionInsertResult, error)
	InsertMany(ctx context.Context, documents []interface{}) (*mongodb.CollectionInsertManyResult, error)
	Upsert(ctx context.Context, selector interface{}, update interface{}) (*mongodb.CollectionUpdateResult, error)
	UpsertById(ctx context.Context, id interface{}, update interface{}) (*mongodb.CollectionUpdateResult, error)
	UpdateById(ctx context.Context, id interface{}, update interface{}) (*mongodb.CollectionUpdateResult, error)
	Update(ctx context.Context, selector interface{}, update interface{}) (*mongodb.CollectionUpdateResult, error)
	UpdateOne(ctx context.Context, selector interface{}, update interface{}) (*mongodb.CollectionUpdateResult, error)
	UpdateMany(ctx context.Context, selector interface{}, update interface{}) (*mongodb.CollectionUpdateResult, error)
	Delete(ctx context.Context, selector interface{}) (*mongodb.CollectionDeleteResult, error)
	DeleteMany(ctx context.Context, selector interface{}) (*mongodb.CollectionDeleteResult, error)
	DeleteById(ctx context.Context, id interface{}) (*mongodb.CollectionDeleteResult, error)
	Aggregate(ctx context.Context, pipeline interface{}, results interface{}) error
	NewLockClient() *lock.Client
}

type MongoCursor added in v1.2.0

type MongoCursor interface {
	mongodb.Cursor
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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