builder

package
v3.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Overview

Package builder help us to write aggregates, filters, update maps simpler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func S

func S(operators ...Operator) bson.M

S receives operators as parameters and returns a bson.M that can be used in filters, stages, etc.

Types

type BaseOperator

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

BaseOperator is a simple operator struct that implementes the Operator interface.

func (*BaseOperator) GetKey

func (operator *BaseOperator) GetKey() string

GetKey function returns the operator's key.

func (*BaseOperator) GetVal

func (operator *BaseOperator) GetVal() interface{}

GetVal function returns the operator's value.

type Operator

type Operator interface {
	GetKey() string
	GetVal() interface{}
}

Operator is an interface that should be implemented by structs used as operators.

func Bucket

func Bucket(groupBy, boundaries, def, output interface{}) Operator

Bucket function returns a mongo $bucket operator used in aggregations.

func BucketAuto

func BucketAuto(groupBy, buckets, output, granularity interface{}) Operator

BucketAuto function returns a mongo $bucketAuto operator used in aggregations.

func CollStats

func CollStats(latencyStats, storageStats, count interface{}) Operator

CollStats function returns a mongo $collStats operator used in aggregations.

func CurrentOp

func CurrentOp(allUsers, idleConnections, idleCursors, idleSessions, localOps interface{}) Operator

CurrentOp function returns a mongo $currentOp operator used in aggregations.

func Group

func Group(ID interface{}, params bson.M) Operator

Group function returns a mongo $group operator used in aggregations.

func Lookup

func Lookup(from, localField, foreignField, as interface{}) Operator

Lookup function returns a mongo $lookup operator used in aggregations.

func Merge

func Merge(into, on, let, whenMatched, whenNotMatched interface{}) Operator

Merge function returns a mongo $merge operator used in aggregations.

func New

func New(key string, val interface{}) Operator

New function creates a new base operator with the specified key and value

func ReplaceRoot

func ReplaceRoot(newRoot interface{}) Operator

ReplaceRoot function returns a mongo $replaceRoot operator used in aggregations.

func Sample

func Sample(size interface{}) Operator

Sample function returns a mongo sample operator used in aggregations.

func UncorrelatedLookup

func UncorrelatedLookup(from, let, pipeline, as interface{}) Operator

UncorrelatedLookup function returns a mongo $lookup operator used in aggregations.

func Unwind

func Unwind(path, includeArrayIndex, preserveNullAndEmptyArrays interface{}) Operator

Unwind function returns a mongo $unwind operator used in aggregations.

type SMap

type SMap struct {
	Operators []Operator
}

SMap is simple map that can be substitute of `bson.M` to have a simpler map structure for queries, aggregations, etc.

func (*SMap) ToMap

func (s *SMap) ToMap() bson.M

ToMap function converts our SMap to bson.M for use in filters, stages, etc.

Jump to

Keyboard shortcuts

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