pipeline

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder represents a fluent aggregation pipeline builder

func Group

func Group(id any, fields bson.M) *Builder

Group creates a $group stage (standalone function)

func Limit

func Limit(limit int64) *Builder

Limit creates a $limit stage (standalone function)

func Match

func Match(filterBuilder *filter.Builder) *Builder

Match creates a $match stage (standalone function)

func MatchRaw

func MatchRaw(filter bson.M) *Builder

MatchRaw creates a $match stage with raw filter (standalone function)

func New

func New() *Builder

New creates a new pipeline builder

func Project

func Project(fields bson.M) *Builder

Project creates a $project stage (standalone function)

func Skip

func Skip(skip int64) *Builder

Skip creates a $skip stage (standalone function)

func Sort

func Sort(sorts bson.D) *Builder

Sort creates a $sort stage (standalone function)

func SortMap

func SortMap(sorts map[string]int) *Builder

SortMap creates a $sort stage with map (standalone function)

func (*Builder) AddFields

func (b *Builder) AddFields(fields bson.M) *Builder

AddFields adds an $addFields stage to the pipeline

func (*Builder) Build

func (b *Builder) Build() []bson.M

Build returns the pipeline as a slice of bson.M

func (*Builder) Count

func (b *Builder) Count(field string) *Builder

Count adds a $count stage to the pipeline

func (*Builder) Facet

func (b *Builder) Facet(facets map[string][]bson.M) *Builder

Facet adds a $facet stage to the pipeline

func (*Builder) Group

func (b *Builder) Group(id any, fields bson.M) *Builder

Group adds a $group stage to the pipeline

func (*Builder) Limit

func (b *Builder) Limit(limit int64) *Builder

Limit adds a $limit stage to the pipeline

func (*Builder) Lookup

func (b *Builder) Lookup(from, localField, foreignField, as string) *Builder

Lookup adds a $lookup stage to the pipeline

func (*Builder) Match

func (b *Builder) Match(filterBuilder *filter.Builder) *Builder

Match adds a $match stage to the pipeline

func (*Builder) MatchRaw

func (b *Builder) MatchRaw(filter bson.M) *Builder

MatchRaw adds a $match stage with raw bson.M filter

func (*Builder) Project

func (b *Builder) Project(fields bson.M) *Builder

Project adds a $project stage to the pipeline

func (*Builder) Raw

func (b *Builder) Raw(stage bson.M) *Builder

Raw adds a custom stage to the pipeline

func (*Builder) ReplaceRoot

func (b *Builder) ReplaceRoot(newRoot any) *Builder

ReplaceRoot adds a $replaceRoot stage to the pipeline

func (*Builder) Sample

func (b *Builder) Sample(size int64) *Builder

Sample adds a $sample stage to the pipeline

func (*Builder) Skip

func (b *Builder) Skip(skip int64) *Builder

Skip adds a $skip stage to the pipeline

func (*Builder) Sort

func (b *Builder) Sort(sorts bson.D) *Builder

Sort adds a $sort stage to the pipeline

func (*Builder) SortMap

func (b *Builder) SortMap(sorts map[string]int) *Builder

SortMap adds a $sort stage using a map (converted to bson.D for ordered sorting)

func (*Builder) ToBSONArray

func (b *Builder) ToBSONArray() bson.A

ToBSONArray converts the pipeline to a bson.A for compatibility

func (*Builder) Unwind

func (b *Builder) Unwind(path string) *Builder

Unwind adds an $unwind stage to the pipeline

func (*Builder) UnwindWithOptions

func (b *Builder) UnwindWithOptions(path string, preserveNullAndEmptyArrays bool, includeArrayIndex string) *Builder

UnwindWithOptions adds an $unwind stage with additional options

Jump to

Keyboard shortcuts

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