mongo

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 6 Imported by: 0

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)
	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