mongo

package
v0.1.984 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultMongoClientOptions

func DefaultMongoClientOptions(opts MongoClientOptions) *options.ClientOptions

func IndexNameText added in v0.1.693

func IndexNameText(ressource string) string

func IndexNameVector added in v0.1.693

func IndexNameVector(ressource string) string

func NewMongoClient

func NewMongoClient(ctx context.Context, retryOpts helper.RetryOptions, opts options.ClientOptions) (contract.MongoClient, error)

Types

type Blackbox

type Blackbox interface {
	// contains filtered or unexported methods
}

type Client

type Client interface {
	Blackbox
	contract.DBOperator
	contract.MongoOperator
}

func NewClient

func NewClient(ctx context.Context, d Dependencies, opts ClientOptions) (Client, error)

func NewNoopClient added in v0.1.83

func NewNoopClient() Client

type ClientOption added in v0.1.38

type ClientOption = contract.Opt[ClientOptions]

func WithCreateCollections added in v0.1.38

func WithCreateCollections(x ...contract.CreateCollectionsOptions) ClientOption

func WithCreateIndexes added in v0.1.38

func WithCreateIndexes(x ...contract.CreateIndexesOptions) ClientOption

func WithCreateSearchIndexes added in v0.1.38

func WithCreateSearchIndexes(x ...contract.CreateSearchIndexesOptions) ClientOption

func WithDB added in v0.1.44

func WithDB(x string) ClientOption

type ClientOptions added in v0.1.38

type ClientOptions struct {
	DB            string
	Collections   []contract.CreateCollectionsOptions
	Indexes       []contract.CreateIndexesOptions
	SearchIndexes []contract.CreateSearchIndexesOptions
}

func ApplyClientOptions added in v0.1.38

func ApplyClientOptions(opts *ClientOptions, modifiers ...ClientOption) ClientOptions

type DefaultTool added in v0.1.11

type DefaultTool struct {
	T *contract.Tool[Client]
}

func NewTool

func NewTool(c Client, opts contract.ToolOptions[Client]) *DefaultTool

func (*DefaultTool) Close added in v0.1.13

func (d *DefaultTool) Close(ctx context.Context) error

Close closes the underlying client.

func (*DefaultTool) Collection added in v0.1.43

func (d *DefaultTool) Collection(ctx context.Context, db, collection string) (contract.MongoCollection, error)

Collection returns a MongoDB collection handle for the specified database and collection name.

func (*DefaultTool) CombineM added in v0.1.11

func (d *DefaultTool) CombineM(ctx context.Context, op contract.BSONOperator, m ...bson.M) (bson.M, error)

CombineM combines multiple bson.M into a single bson.M using the given operator.

func (*DefaultTool) CountFromPipeline added in v0.1.771

func (d *DefaultTool) CountFromPipeline(ctx context.Context, opts contract.CountFromPipelineOptions) (int64, error)

CountFromPipeline runs an aggregation pipeline to count documents and returns the count.

func (*DefaultTool) Database added in v0.1.43

func (d *DefaultTool) Database(ctx context.Context, db string) (contract.MongoDatabase, error)

Database returns a MongoDB database handle for the specified database name.

func (*DefaultTool) Filter added in v0.1.11

func (d *DefaultTool) Filter(ctx context.Context, opts contract.FilterOptions) (bson.M, error)

Filter builds a BSON filter from query parameters. MatchBehavior must be a valid field-level operator (e.g. "$in", "$eq"). Do not use top-level operators like "$and" or "$or".

func (*DefaultTool) FilterByAllElemsInArray added in v0.1.11

func (d *DefaultTool) FilterByAllElemsInArray(ctx context.Context, opts contract.ElemsInArrayFilterOptions) (bson.M, error)

FilterByAllElemsInArray matches documents where an array contains all specified elements at minimum.

func (*DefaultTool) FilterByElemMatch added in v0.1.11

func (d *DefaultTool) FilterByElemMatch(ctx context.Context, opts contract.ElemMatchFilterOptions) (bson.M, error)

FilterByElemMatch finds documents where an array field contains a specific element.

func (*DefaultTool) FilterByElemsInArray added in v0.1.11

func (d *DefaultTool) FilterByElemsInArray(ctx context.Context, opts contract.ElemsInArrayFilterOptions) (bson.M, error)

FilterByElemsInArray finds documents where an array field contains any of the specified elements.

func (*DefaultTool) FilterByExactDate added in v0.1.11

func (d *DefaultTool) FilterByExactDate(ctx context.Context, opts contract.DateFilterOptions) (bson.D, error)

FilterByExactDate constructs a MongoDB filter to match documents with an exact date. It matches documents where a given date field is exactly equal to a specified reference date.

func (*DefaultTool) FilterByFieldInArray added in v0.1.11

func (d *DefaultTool) FilterByFieldInArray(ctx context.Context, opts contract.FieldInArrayFilterOptions) (bson.M, error)

FilterByFieldInArray matches documents where a field contains one of the specified elements.

func (*DefaultTool) FilterByFutureDate added in v0.1.11

func (d *DefaultTool) FilterByFutureDate(ctx context.Context, opts contract.DateFilterOptions) (bson.D, error)

FilterByFutureDate constructs a MongoDB filter to match documents with a future date. It matches documents where a given date field is after a specified reference date.

func (*DefaultTool) FilterByPastDate added in v0.1.11

func (d *DefaultTool) FilterByPastDate(ctx context.Context, opts contract.DateFilterOptions) (bson.D, error)

FilterByPastDate constructs a MongoDB filter to match documents with a past date. It matches documents where a given date field is before a specified reference date.

func (*DefaultTool) ProcessChangeStream added in v0.1.11

func (d *DefaultTool) ProcessChangeStream(ctx context.Context, opts contract.ProcessChangeStreamOptions) error

ProcessChangeStream processes a MongoDB change stream and sends updates to an output channel.

func (*DefaultTool) RunPipeline added in v0.1.79

func (d *DefaultTool) RunPipeline(ctx context.Context, opts contract.RunPipelineOptions) ([]any, error)

RunPipeline executes a custom aggregation pipeline and returns decoded results.

func (*DefaultTool) Search added in v0.1.11

Search executes a search query and returns matching documents with pagination support.

func (*DefaultTool) WatchCollection added in v0.1.11

func (d *DefaultTool) WatchCollection(ctx context.Context, opts contract.WatchCollectionOptions) error

WatchCollection listens for changes in a specific collection and streams updates.

func (*DefaultTool) WatchDB added in v0.1.11

func (d *DefaultTool) WatchDB(ctx context.Context, opts contract.WatchDBOptions) error

WatchDB listens for changes across an entire database and streams updates.

func (*DefaultTool) WithTransaction added in v0.1.34

func (d *DefaultTool) WithTransaction(ctx context.Context, fn func(ctx context.Context) error) error

WithTransaction runs a function within a MongoDB transaction.

type Dependencies added in v0.1.8

type Dependencies struct {
	C contract.MongoClient
	S contract.StringOperator
}

type MongoClientOptions added in v0.1.14

type MongoClientOptions struct {
	ConnString      string
	AppName         string
	MaxPoolSize     uint64
	MaxConnIdleTime time.Duration
	R               Registrars
}

type Registrars added in v0.1.317

type Registrars []func(reg *bson.Registry)

type Tool added in v0.1.245

type Tool interface {
	contract.MongoOperator
}

Jump to

Keyboard shortcuts

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