aggregator

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aggregator

type Aggregator[T any] struct {
	// contains filtered or unexported fields
}

func NewAggregator

func NewAggregator[T any](collection *mongo.Collection, dbCallbacks *callback.Callback, fields []*field.Filed) *Aggregator[T]

func (*Aggregator[T]) Aggregate

func (a *Aggregator[T]) Aggregate(ctx context.Context, opts ...options.Lister[options.AggregateOptions]) ([]*T, error)

func (*Aggregator[T]) AggregateWithParse

func (a *Aggregator[T]) AggregateWithParse(ctx context.Context, result any, opts ...options.Lister[options.AggregateOptions]) error

AggregateWithParse is used to parse the result of the aggregation result must be a pointer to a slice

func (*Aggregator[T]) ModelHook added in v2.2.0

func (a *Aggregator[T]) ModelHook(modelHook any) *Aggregator[T]

func (*Aggregator[T]) Pipeline

func (a *Aggregator[T]) Pipeline(pipeline any) *Aggregator[T]

func (*Aggregator[T]) RegisterAfterHooks added in v2.2.0

func (a *Aggregator[T]) RegisterAfterHooks(hooks ...afterHookFn) *Aggregator[T]

func (*Aggregator[T]) RegisterBeforeHooks added in v2.2.0

func (a *Aggregator[T]) RegisterBeforeHooks(hooks ...beforeHookFn) *Aggregator[T]

type IAggregator

type IAggregator[T any] interface {
	Aggregate(ctx context.Context, opts ...options.Lister[options.AggregateOptions]) ([]*T, error)
	AggregateWithParse(ctx context.Context, result any, opts ...options.Lister[options.AggregateOptions]) error
}

type OpContext added in v2.2.0

type OpContext struct {
	Col      *mongo.Collection `opt:"-"`
	Pipeline any               `opt:"-"`

	Fields []*field.Filed

	MongoOptions any
	ModelHook    any
	StartTime    time.Time

	Result any
}

func NewOpContext added in v2.2.0

func NewOpContext(col *mongo.Collection, pipeline any, opts ...OpContextOption) *OpContext

type OpContextOption added in v2.2.0

type OpContextOption func(*OpContext)

func WithFields added in v2.2.0

func WithFields(fields []*field.Filed) OpContextOption

func WithModelHook added in v2.2.0

func WithModelHook(modelHook any) OpContextOption

func WithMongoOptions added in v2.2.0

func WithMongoOptions(mongoOptions any) OpContextOption

func WithResult added in v2.2.0

func WithResult(result any) OpContextOption

func WithStartTime added in v2.2.0

func WithStartTime(startTime time.Time) OpContextOption

Jump to

Keyboard shortcuts

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