aggregation

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package aggregation contains helper functions to construct [mongodb aggregation operators](https://docs.mongodb.com/manual/reference/operator/)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type A

type A = primitive.A

An A alias primitive.A

type AccumulatorOperator added in v0.3.2

type AccumulatorOperator M

type BucketAutoStage

type BucketAutoStage M

BucketAutoStage returned from BucketAuto

func BucketAuto

func BucketAuto(groupBy interface{}, buckets int) BucketAutoStage

BucketAuto categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression. Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets. https://docs.mongodb.com/manual/reference/operator/aggregation/bucketAuto/

func (BucketAutoStage) SetGranularity

func (stage BucketAutoStage) SetGranularity(v string) BucketAutoStage

SetGranularity option

func (BucketAutoStage) SetOutput

func (stage BucketAutoStage) SetOutput(document interface{}) BucketAutoStage

SetOutput option

type BucketStage

type BucketStage M

BucketStage returned from Bucket

func Bucket

func Bucket(groupBy, boundaries interface{}) BucketStage

Bucket categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/bucket/

func (BucketStage) SetDefault

func (stage BucketStage) SetDefault(literal interface{}) BucketStage

SetDefault option

func (BucketStage) SetOutput

func (stage BucketStage) SetOutput(document interface{}) BucketStage

SetOutput option

type CollStatsStage

type CollStatsStage M

CollStatsStage returned from CollStats

func CollStats

func CollStats() CollStatsStage

CollStats returns statistics regarding a collection or view. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/collStats/

func (CollStatsStage) SetCount

func (stage CollStatsStage) SetCount() CollStatsStage

SetCount option

func (CollStatsStage) SetLatencyStats

func (stage CollStatsStage) SetLatencyStats(histograms bool) CollStatsStage

SetLatencyStats option

func (CollStatsStage) SetStorageStats

func (stage CollStatsStage) SetStorageStats(scale int64) CollStatsStage

SetStorageStats option

type ConvertOperator

type ConvertOperator M

ConvertOperator returned from Convert

func Convert

func Convert(input, to interface{}) ConvertOperator

Convert a value to a specified type. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/convert/

func (ConvertOperator) SetOnError

func (op ConvertOperator) SetOnError(expr interface{}) ConvertOperator

SetOnError option

func (ConvertOperator) SetOnNull

func (op ConvertOperator) SetOnNull(expr interface{}) ConvertOperator

SetOnNull option

type DateFromPartsCOperator

type DateFromPartsCOperator M

DateFromPartsCOperator returned from DateFromParts

func DateFromPartsC

func DateFromPartsC(year interface{}) DateFromPartsCOperator

DateFromPartsC constructs and returns a Date object given the calendar date’s constituent properties. https://docs.mongodb.com/manual/reference/operator/aggregation/dateFromParts/

func (DateFromPartsCOperator) SetDay

func (op DateFromPartsCOperator) SetDay(v interface{}) DateFromPartsCOperator

SetDay option

func (DateFromPartsCOperator) SetHour

func (op DateFromPartsCOperator) SetHour(v interface{}) DateFromPartsCOperator

SetHour option

func (DateFromPartsCOperator) SetMillisecond

func (op DateFromPartsCOperator) SetMillisecond(v interface{}) DateFromPartsCOperator

SetMillisecond option

func (DateFromPartsCOperator) SetMinute

func (op DateFromPartsCOperator) SetMinute(v interface{}) DateFromPartsCOperator

SetMinute option

func (DateFromPartsCOperator) SetMonth

func (op DateFromPartsCOperator) SetMonth(v interface{}) DateFromPartsCOperator

SetMonth option

func (DateFromPartsCOperator) SetSecond

func (op DateFromPartsCOperator) SetSecond(v interface{}) DateFromPartsCOperator

SetSecond option

func (DateFromPartsCOperator) SetTimezone

func (op DateFromPartsCOperator) SetTimezone(v interface{}) DateFromPartsCOperator

SetTimezone option

type DateFromPartsWOperator

type DateFromPartsWOperator M

DateFromPartsWOperator returned from DateFromWeekParts

func DateFromPartsW

func DateFromPartsW(year interface{}) DateFromPartsWOperator

DateFromPartsW constructs and returns a Date object given the ISO week date’s constituent properties. https://docs.mongodb.com/manual/reference/operator/aggregation/dateFromParts/

func (DateFromPartsWOperator) SetDayOfWeek

func (op DateFromPartsWOperator) SetDayOfWeek(v interface{}) DateFromPartsWOperator

SetDayOfWeek option

func (DateFromPartsWOperator) SetHour

func (op DateFromPartsWOperator) SetHour(v interface{}) DateFromPartsWOperator

SetHour option

func (DateFromPartsWOperator) SetMillisecond

func (op DateFromPartsWOperator) SetMillisecond(v interface{}) DateFromPartsWOperator

SetMillisecond option

func (DateFromPartsWOperator) SetMinute

func (op DateFromPartsWOperator) SetMinute(v interface{}) DateFromPartsWOperator

SetMinute option

func (DateFromPartsWOperator) SetSecond

func (op DateFromPartsWOperator) SetSecond(v interface{}) DateFromPartsWOperator

SetSecond option

func (DateFromPartsWOperator) SetTimezone

func (op DateFromPartsWOperator) SetTimezone(v interface{}) DateFromPartsWOperator

SetTimezone option

func (DateFromPartsWOperator) SetWeek

func (op DateFromPartsWOperator) SetWeek(v interface{}) DateFromPartsWOperator

SetWeek option

type DateFromStringOperator

type DateFromStringOperator M

DateFromStringOperator returned from DateFromString

func DateFromString

func DateFromString(dateString interface{}) DateFromStringOperator

DateFromString converts a date/time string to a date object. New in version 3.6. https://docs.mongodb.com/manual/reference/operator/aggregation/dateFromString/

func (DateFromStringOperator) SetFormat

func (op DateFromStringOperator) SetFormat(v interface{}) DateFromStringOperator

SetFormat option

func (DateFromStringOperator) SetOnError

func (op DateFromStringOperator) SetOnError(v interface{}) DateFromStringOperator

SetOnError option

func (DateFromStringOperator) SetOnNull

func (op DateFromStringOperator) SetOnNull(v interface{}) DateFromStringOperator

SetOnNull option

func (DateFromStringOperator) SetTimezone

func (op DateFromStringOperator) SetTimezone(v interface{}) DateFromStringOperator

SetTimezone option

type DateToPartsOperator

type DateToPartsOperator M

DateToPartsOperator returned from DateToParts

func DateToParts

func DateToParts(date interface{}) DateToPartsOperator

DateToParts returns a document containing the constituent parts of a date. New in version 3.6. https://docs.mongodb.com/manual/reference/operator/aggregation/dateToParts/

func (DateToPartsOperator) SetISO8601

func (op DateToPartsOperator) SetISO8601(v bool) DateToPartsOperator

SetISO8601 option

func (DateToPartsOperator) SetTimezone

func (op DateToPartsOperator) SetTimezone(v interface{}) DateToPartsOperator

SetTimezone option

type DateToStringOperator

type DateToStringOperator M

DateToStringOperator returned from DateToString

func DateToString

func DateToString(date interface{}) DateToStringOperator

DateToString converts a date object to a string according to a user-specified format. https://docs.mongodb.com/manual/reference/operator/aggregation/dateToString/

func (DateToStringOperator) SetFormat

SetFormat option required before version 4.0

func (DateToStringOperator) SetTimezone

func (op DateToStringOperator) SetTimezone(v interface{}) DateToStringOperator

SetTimezone option

type DayOfMonthOperator

type DayOfMonthOperator M

DayOfMonthOperator returned from DayOfMonth

func DayOfMonth

func DayOfMonth(date interface{}) DayOfMonthOperator

DayOfMonth returns the day of the month for a date as a number between 1 and 31. https://docs.mongodb.com/manual/reference/operator/aggregation/dayOfMonth/

func (DayOfMonthOperator) SetTimezone

func (op DayOfMonthOperator) SetTimezone(v interface{}) DayOfMonthOperator

SetTimezone option New in version 3.6.

type DayOfWeekOperator

type DayOfWeekOperator M

DayOfWeekOperator returned from DayOfMonth

func DayOfWeek

func DayOfWeek(date interface{}) DayOfWeekOperator

DayOfWeek returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday). https://docs.mongodb.com/manual/reference/operator/aggregation/dayOfWeek/

func (DayOfWeekOperator) SetTimezone

func (op DayOfWeekOperator) SetTimezone(v interface{}) DayOfWeekOperator

SetTimezone option New in version 3.6.

type DayOfYearOperator

type DayOfYearOperator M

DayOfYearOperator returned from DayOfYear

func DayOfYear

func DayOfYear(date interface{}) DayOfYearOperator

DayOfYear returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday). https://docs.mongodb.com/manual/reference/operator/aggregation/dayOfYear/

func (DayOfYearOperator) SetTimezone

func (op DayOfYearOperator) SetTimezone(v interface{}) DayOfYearOperator

SetTimezone option New in version 3.6.

type DerivativeOperator added in v0.3.2

type DerivativeOperator M

func Derivative added in v0.3.2

func Derivative(inputExpr interface{}) DerivativeOperator

Derivative returns the average rate of change within the specified window. New in version 5.0.

func (DerivativeOperator) SetUnit added in v0.3.2

type DerivativeUnit added in v0.3.2

type DerivativeUnit string
const (
	DUWeek        DerivativeUnit = "week"
	DUDay         DerivativeUnit = "day"
	DUHour        DerivativeUnit = "hour"
	DUMinute      DerivativeUnit = "minute"
	DUSecond      DerivativeUnit = "second"
	DUMillisecond DerivativeUnit = "millisecond"
)

type FilterOperator

type FilterOperator M

FilterOperator returned from Filter

func Filter

func Filter(input interface{}, cond interface{}) FilterOperator

Filter selects a subset of the array to return an array with only the elements that match the filter condition. https://docs.mongodb.com/manual/reference/operator/aggregation/filter/

func (FilterOperator) SetAs

func (op FilterOperator) SetAs(v string) FilterOperator

SetAs option

type GeoNearStage

type GeoNearStage M

GeoNearStage returned from GeoNear

func GeoNear

func GeoNear(near interface{}, distanceField string) GeoNearStage

GeoNear returns an ordered stream of documents based on the proximity to a geospatial point. Incorporates the functionality of $match, $sort, and $limit for geospatial data. The output documents include an additional distance field and can include a location identifier field. https://docs.mongodb.com/manual/reference/operator/aggregation/geoNear/

func (GeoNearStage) SetDistanceMultiplier

func (stage GeoNearStage) SetDistanceMultiplier(v float64) GeoNearStage

SetDistanceMultiplier option

func (GeoNearStage) SetIncludeLocs

func (stage GeoNearStage) SetIncludeLocs(v string) GeoNearStage

SetIncludeLocs option

func (GeoNearStage) SetKey

func (stage GeoNearStage) SetKey(v string) GeoNearStage

SetKey option

func (GeoNearStage) SetMaxDistance

func (stage GeoNearStage) SetMaxDistance(v float64) GeoNearStage

SetMaxDistance option

func (GeoNearStage) SetMinDistance

func (stage GeoNearStage) SetMinDistance(v float64) GeoNearStage

SetMinDistance option

func (GeoNearStage) SetQuery

func (stage GeoNearStage) SetQuery(v interface{}) GeoNearStage

SetQuery option

func (GeoNearStage) SetSpherical

func (stage GeoNearStage) SetSpherical(v bool) GeoNearStage

SetSpherical option

func (GeoNearStage) SetUniqueDocs

func (stage GeoNearStage) SetUniqueDocs(v bool) GeoNearStage

SetUniqueDocs option

type GraphLookupStage

type GraphLookupStage M

GraphLookupStage stage

func GraphLookup

func GraphLookup(from string, startWith interface{}, connectFromField string, connectToField string, as string) GraphLookupStage

GraphLookup performs a recursive search on a collection. To each output document, adds a new array field that contains the traversal results of the recursive search for that document. https://docs.mongodb.com/manual/reference/operator/aggregation/graphLookup/

func (GraphLookupStage) SetDepthField

func (stage GraphLookupStage) SetDepthField(v string) GraphLookupStage

SetDepthField option

func (GraphLookupStage) SetMaxDepth

func (stage GraphLookupStage) SetMaxDepth(v int) GraphLookupStage

SetMaxDepth option

func (GraphLookupStage) SetRestrictSearchWithMatch

func (stage GraphLookupStage) SetRestrictSearchWithMatch(v interface{}) GraphLookupStage

SetRestrictSearchWithMatch option

type HourOperator

type HourOperator M

HourOperator returned from Hour

func Hour

func Hour(date interface{}) HourOperator

Hour returns the hour for a date as a number between 0 and 23. https://docs.mongodb.com/manual/reference/operator/aggregation/hour/

func (HourOperator) SetTimezone

func (op HourOperator) SetTimezone(v interface{}) HourOperator

SetTimezone option New in version 3.6.

type ISODayOfWeekOperator

type ISODayOfWeekOperator M

ISODayOfWeekOperator returned from ISODayOfWeek

func ISODayOfWeek

func ISODayOfWeek(date interface{}) ISODayOfWeekOperator

ISODayOfWeek returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday). New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/isoDayOfWeek/

func (ISODayOfWeekOperator) SetTimezone

func (op ISODayOfWeekOperator) SetTimezone(v interface{}) ISODayOfWeekOperator

SetTimezone option New in version 3.6.

type ISOWeekOperator

type ISOWeekOperator M

ISOWeekOperator returned from ISOWeek

func ISOWeek

func ISOWeek(date interface{}) ISOWeekOperator

ISOWeek returns the week number in ISO 8601 format, ranging from 1 to 53. Week numbers start at 1 with the week (Monday through Sunday) that contains the year’s first Thursday. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/isoWeek/

func (ISOWeekOperator) SetTimezone

func (op ISOWeekOperator) SetTimezone(v interface{}) ISOWeekOperator

SetTimezone option New in version 3.6.

type ISOWeekYearOperator

type ISOWeekYearOperator M

ISOWeekYearOperator returned from ISOWeek

func ISOWeekYear

func ISOWeekYear(date interface{}) ISOWeekYearOperator

ISOWeekYear returns the year number in ISO 8601 format. The year starts with the Monday of week 1 and ends with the Sunday of the last week. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/isoWeekYear/

func (ISOWeekYearOperator) SetTimezone

func (op ISOWeekYearOperator) SetTimezone(v interface{}) ISOWeekYearOperator

SetTimezone option New in version 3.6.

type IndexOfArrayOperator

type IndexOfArrayOperator M

IndexOfArrayOperator returned from IndexOfArray

func IndexOfArray

func IndexOfArray(array, search interface{}) IndexOfArrayOperator

IndexOfArray searches an array for an occurence of a specified value and returns the array index of the first occurence. If the substring is not found, returns -1. https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfArray/

func (IndexOfArrayOperator) SetEnd

func (op IndexOfArrayOperator) SetEnd(expr interface{}) IndexOfArrayOperator

SetEnd expression

func (IndexOfArrayOperator) SetStart

func (op IndexOfArrayOperator) SetStart(expr interface{}) IndexOfArrayOperator

SetStart expression

type IndexOfBytesOperator

type IndexOfBytesOperator M

IndexOfBytesOperator returned from IndexOfBytes

func IndexOfBytes

func IndexOfBytes(stringExpr, substringExpr interface{}) IndexOfBytesOperator

IndexOfBytes searches a string for an occurence of a substring and returns the UTF-8 byte index of the first occurence. If the substring is not found, returns -1. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfBytes/

type IndexOfCPOperator

type IndexOfCPOperator M

IndexOfCPOperator returned from IndexOfCP

func IndexOfCP

func IndexOfCP(stringExpr, subStringExpr interface{}) IndexOfCPOperator

IndexOfCP searches a string for an occurence of a substring and returns the UTF-8 code point index of the first occurence. If the substring is not found, returns -1 https://docs.mongodb.com/manual/reference/operator/aggregation/indexOfCP/

func (IndexOfCPOperator) SetEnd

func (op IndexOfCPOperator) SetEnd(expr interface{}) IndexOfCPOperator

SetEnd expression

func (IndexOfCPOperator) SetStart

func (op IndexOfCPOperator) SetStart(expr interface{}) IndexOfCPOperator

SetStart expression

type IntegralOperator added in v0.3.2

type IntegralOperator M

func Integral added in v0.3.2

func Integral(inputExpr interface{}) IntegralOperator

Integral returns the approximation of the area under a curve. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/integral/

func (IntegralOperator) SetUnit added in v0.3.2

type IntegralUnit added in v0.3.2

type IntegralUnit string
const (
	IUWeek        IntegralUnit = "week"
	IUDay         IntegralUnit = "day"
	IUHour        IntegralUnit = "hour"
	IUMinute      IntegralUnit = "minute"
	IUSecond      IntegralUnit = "second"
	IUMillisecond IntegralUnit = "millisecond"
)

type LTrimOperator

type LTrimOperator M

LTrimOperator returned from LTrim

func LTrim

func LTrim(input interface{}) LTrimOperator

LTrim removes whitespace characters, including null, or the specified characters from the beginning of a string. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/ltrim/

func (LTrimOperator) SetChars

func (op LTrimOperator) SetChars(expr interface{}) LTrimOperator

SetChars option

type M

type M = primitive.M

M alias primitive.M

func ACos

func ACos(number interface{}) M

ACos returns the inverse cosine (arc cosine) of a value in radians. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/acos/

func ACosH

func ACosH(number interface{}) M

ACosH returns the inverse hyperbolic cosine (hyperbolic arc cosine) of a value in radians. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/acos/

func ASin

func ASin(number interface{}) M

ASin returns the inverse sin (arc sine) of a value in radians. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/asin/

func ASinH

func ASinH(number interface{}) M

ASinH returns the inverse hyperbolic sine (hyperbolic arc sine) of a value in radians. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/asin/

func ATan

func ATan(number interface{}) M

ATan returns the inverse tangent (arc tangent) of a value in radians. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/atan/

func ATan2

func ATan2(y, x interface{}) M

ATan2 returns the inverse tangent (arc tangent) of y / x in radians, New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/atan2/

func ATanH

func ATanH(number interface{}) M

ATanH returns the inverse hyperbolic tangent (hyperbolic arc tangent) of a value in radians. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/atan/

func Abs

func Abs(number interface{}) M

Abs returns the absolute value of a number. https://docs.mongodb.com/manual/reference/operator/aggregation/abs/

func Accumulator added in v0.3.2

func Accumulator(
	init primitive.JavaScript,
	initArgs interface{},
	accumulate primitive.JavaScript,
	accumulateArgs interface{},
	merge primitive.JavaScript,
	finalize primitive.JavaScript,
) M

Accumulator defines a custom accumulator function. New in version 4.4. https://docs.mongodb.com/manual/reference/operator/aggregation/accumulator/

func Add

func Add(numberOrDate ...interface{}) M

Add numbers to return the sum, or adds numbers and a date to return a new date. If adding numbers and a date, treats the numbers as milliseconds. Accepts any number of argument expressions, but at most, one expression can resolve to a date. https://docs.mongodb.com/manual/reference/operator/aggregation/add/

func AddFields

func AddFields(fields interface{}) M

AddFields to documents. Similar to $project, $addFields reshapes each document in the stream; specifically, by adding new fields to output documents that contain both the existing fields from the input documents and the newly added fields. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/addFields

func AddToSet

func AddToSet(expr interface{}) M

AddToSet returns an array of all unique values that results from applying an expression to each document in a group of documents that share the same group by key. Order of the elements in the output array is unspecified. $addToSet is only available in the $group stage. https://docs.mongodb.com/manual/reference/operator/aggregation/addToSet/

func AllElementsTrue

func AllElementsTrue(set interface{}) M

AllElementsTrue returns true if no element of a set evaluates to false, otherwise, returns false. https://docs.mongodb.com/manual/reference/operator/aggregation/allElementsTrue/

func And

func And(expr ...interface{}) M

And returns true only when all its expressions evaluate to true. https://docs.mongodb.com/manual/reference/operator/aggregation/and

func AnyElementsTrue

func AnyElementsTrue(set interface{}) M

AnyElementsTrue returns true if any elements of a set evaluate to true; otherwise, returns false. https://docs.mongodb.com/manual/reference/operator/aggregation/anyElementTrue/

func ArrayElemAt

func ArrayElemAt(array, index interface{}) M

ArrayElemAt returns the element at the specified array index. https://docs.mongodb.com/manual/reference/operator/aggregation/arrayElemAt

func ArrayToObject

func ArrayToObject(expr interface{}) M

ArrayToObject converts an array into a single document. https://docs.mongodb.com/manual/reference/operator/aggregation/arrayToObject/

func Avg

func Avg(expr ...interface{}) M

Avg returns the average value of the numeric values. In MongoDB 3.2 and earlier, $avg is available in the $group stage only. https://docs.mongodb.com/manual/reference/operator/aggregation/avg/

func BSONSize added in v0.3.2

func BSONSize(expr interface{}) M

BSONSize returns the size in bytes of a given document (i.e. bsontype Object) when encoded as BSON. https://docs.mongodb.com/manual/reference/operator/aggregation/bsonSize/

func BinarySize added in v0.3.2

func BinarySize(expr interface{}) M

BinarySize returns the size of a given string or binary data value's content in bytes. New in version 4.4. https://docs.mongodb.com/manual/reference/operator/aggregation/binarySize/

func Ceil

func Ceil(number interface{}) M

Ceil returns the smallest integer greater than or equal to the specified number. https://docs.mongodb.com/manual/reference/operator/aggregation/ceil/

func Cmp

func Cmp(left, right interface{}) M

Cmp returns 0 if the two values are equivalent, 1 if the first value is greater than the second, and -1 if the first value is less than the second. https://docs.mongodb.com/manual/reference/operator/aggregation/cmp/

func Concat

func Concat(stringExpr ...interface{}) M

Concat any number of strings. https://docs.mongodb.com/manual/reference/operator/aggregation/concat/

func ConcatArrays

func ConcatArrays(array ...interface{}) M

ConcatArrays concatenates arrays to return the concatenated array. https://docs.mongodb.com/manual/reference/operator/aggregation/concatArrays/

func Cond

func Cond(ifExpr, thenExpr, elseExpr interface{}) M

Cond A ternary operator that evaluates one expression, and depending on the result, returns the value of one of the other two expressions. https://docs.mongodb.com/manual/reference/operator/aggregation/cond/

func Cos

func Cos(number interface{}) M

Cos returns the cosine of a value that is measured in radians. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/cos/

func Count

func Count(outputField string) M

Count returns a count of the number of documents at this stage of the aggregation pipeline. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/count/

func CountAccumulator added in v0.3.2

func CountAccumulator() M

CountAccumulator Returns the number of documents in a group.

$count is available in these stages:

- $bucket - $bucketAuto - $group - $setWindowFields (Available starting in MongoDB 5.0)

https://docs.mongodb.com/manual/reference/operator/aggregation/count-accumulator/

func CovariancePop added in v0.3.2

func CovariancePop(expr1, expr2 interface{}) M

CovariancePop returns the population covariance of two numeric expressions. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/covariancePop/

func CovarianceSamp added in v0.3.2

func CovarianceSamp(expr1, expr2 interface{}) M

CovarianceSamp returns the sample covariance of two numeric expressions. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/covarianceSamp/

func CurrentOp added in v0.3.2

func CurrentOp(options interface{}) M

CurrentOp returns a stream of documents containing information on active and/or dormant operations as well as inactive sessions that are holding locks as part of a transaction. The stage returns a document for each operation or session. To run $currentOp, use the db.aggregate() helper on the admin database. https://docs.mongodb.com/manual/reference/operator/aggregation/currentOp/

func DateTrunc

func DateTrunc(to string, date interface{}, timezone string) M

DateTrunc trunc date to lower precision.

For date=ISODate("2001-02-03T15:04:05.6Z), timezone="UTC":

to="year"   -> ISODate("2001-01-01T00:00:00Z")
to="month"  -> ISODate("2001-02-01T00:00:00Z")
to="day"    -> ISODate("2001-02-03T00:00:00Z")
to="hour"   -> ISODate("2001-02-03T15:00:00Z")
to="minute" -> ISODate("2001-02-03T15:04:00Z")
to="second" -> ISODate("2001-02-03T15:04:05Z")

func DegreesToRadians

func DegreesToRadians(number interface{}) M

DegreesToRadians converts a value from degrees to radians. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/degreesToRadians/

func DenseRank added in v0.3.2

func DenseRank() M

DenseRank returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. There are no gaps in the ranks. Ties receive the same rank. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/denseRank/

func Divide

func Divide(dividend, divisor interface{}) M

Divide one number by another and returns the result. https://docs.mongodb.com/manual/reference/operator/aggregation/divide/

func DocumentNumber added in v0.3.2

func DocumentNumber() M

DocumentNumber returns the position of a document (known as the document number) in the $setWindowFields stage partition. Ties result in different adjacent document numbers. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/documentNumber/

func Eq

func Eq(left, right interface{}) M

Eq returns true if the values are equivalent. https://docs.mongodb.com/manual/reference/operator/aggregation/eq/

func Exp

func Exp(exponent interface{}) M

Exp raises Euler’s number (i.e. e ) to the specified exponent and returns the result. https://docs.mongodb.com/manual/reference/operator/aggregation/exp/

func ExpMovingAvg added in v0.3.2

func ExpMovingAvg(inputExpr interface{}, n int64) M

ExpMovingAvgN returns the exponential moving average for the numeric expression. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/expMovingAvg/

func ExpMovingAvgAlpha added in v0.3.2

func ExpMovingAvgAlpha(inputExpr interface{}, alpha float64) M

ExpMovingAvgAlpha returns the exponential moving average for the numeric expression. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/expMovingAvg/

func Facet

func Facet(outputs interface{}) M

Facet Processes multiple aggregation pipelines within a single stage on the same set of input documents. Enables the creation of multi-faceted aggregations capable of characterizing data across multiple dimensions, or facets, in a single stage. https://docs.mongodb.com/manual/reference/operator/aggregation/facet/

func First

func First(expr interface{}) M

First returns the value that results from applying an expression to the first document in a group of documents that share the same group by key. Only meaningful when documents are in a defined order. $first is only available in the $group stage. https://docs.mongodb.com/manual/reference/operator/aggregation/first/

func FirstOfArray added in v0.3.2

func FirstOfArray(expr interface{}) M

FirstOfArray returns the first element in an array. New in version 4.4. https://docs.mongodb.com/manual/reference/operator/aggregation/first-array-element/

func Floor

func Floor(number interface{}) M

Floor returns the largest integer less than or equal to the specified number. https://docs.mongodb.com/manual/reference/operator/aggregation/floor/

func Function added in v0.3.2

func Function(
	body primitive.JavaScript,
	args interface{},

) M

Function defines a custom function. New in version 4.4. https://docs.mongodb.com/manual/reference/operator/aggregation/function/

func GetField added in v0.3.2

func GetField(field string, inputExpr interface{}) M

GetField returns the value of a specified field from a document. You can use $getField to retrieve the value of fields with names that contain periods (.) or start with dollar signs ($). New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/getField/

func Group

func Group(idAndFields interface{}) M

Group input documents by a specified identifier expression and applies the accumulator expression(s), if specified, to each group. Consumes all input documents and outputs one document per each distinct group. The output documents only contain the identifier field and, if specified, accumulated fields. https://docs.mongodb.com/manual/reference/operator/aggregation/group/

func Gt

func Gt(left, right interface{}) M

Gt returns true if the first value is greater than the second. https://docs.mongodb.com/manual/reference/operator/aggregation/gt/

func Gte

func Gte(left, right interface{}) M

Gte returns true if the first value is greater than or equal to the second. https://docs.mongodb.com/manual/reference/operator/aggregation/gte/

func IfNull

func IfNull(expr, replaceExprIfNull interface{}) M

IfNull returns either the non-null result of the first expression or the result of the second expression if the first expression results in a null result. Null result encompasses instances of undefined values or missing fields. https://docs.mongodb.com/manual/reference/operator/aggregation/ifNull

func In

func In(elem, array interface{}) M

In returns a boolean indicating whether a specified value is in an array https://docs.mongodb.com/manual/reference/operator/aggregation/in

func IndexStats

func IndexStats() M

IndexStats returns statistics regarding the use of each index for the collection. New in version 3.2. https://docs.mongodb.com/manual/reference/operator/aggregation/indexStats/

func IsArray

func IsArray(expr interface{}) M

IsArray determines if the operand is an array. Returns a boolean. https://docs.mongodb.com/manual/reference/operator/aggregation/isArray/

func IsNumber added in v0.3.2

func IsNumber(expr interface{}) M

IsNumber checks if the specified expression resolves to one of the following numeric BSON types:

- Integer - Decimal - Double - Long

$isNumber returns:

true if the expression resolves to a number.
false if the expression resolves to any other BSON type, null, or a missing field.

https://docs.mongodb.com/manual/reference/operator/aggregation/isNumber/

func Last

func Last(expr interface{}) M

Last returns the value that results from applying an expression to the last document in a group of documents that share the same group by key. Only meaningful when documents are in a defined order. $last is only available in the $group stage. https://docs.mongodb.com/manual/reference/operator/aggregation/last/

func LastOfArray added in v0.3.2

func LastOfArray(expr interface{}) M

LastOfArray returns the last element in an array. New in version 4.4. https://docs.mongodb.com/manual/reference/operator/aggregation/last-array-element/

func Let

func Let(vars, in interface{}) M

Let defines variables for use within the scope of a subexpression and returns the result of the subexpression. Accepts named parameters. Accepts any number of argument expressions. https://docs.mongodb.com/manual/reference/operator/aggregation/let/

func Limit

func Limit(n int) M

Limit Passes the first n documents unmodified to the pipeline where n is the specified limit. For each input document, outputs either one document (for the first n documents) or zero documents (after the first n documents). https://docs.mongodb.com/manual/reference/operator/aggregation/limit/

func ListLocalSessions added in v0.3.2

func ListLocalSessions(args interface{}) M

ListLocalSessions lists the sessions cached in memory by the mongod or mongos instance. New in version 3.6. https://docs.mongodb.com/manual/reference/operator/aggregation/listLocalSessions/

func ListSessions

func ListSessions(args interface{}) M

ListSessions that have been active long enough to propagate to the system.sessions collection. New in version 3.6. https://docs.mongodb.com/manual/reference/operator/aggregation/listSessions/

func Literal

func Literal(value interface{}) M

Literal return a value without parsing. Use for values that the aggregation pipeline may interpret as an expression. For example, use a $literal expression to a string that starts with a $ to avoid parsing as a field path. https://docs.mongodb.com/manual/reference/operator/aggregation/literal/

func Ln

func Ln(number interface{}) M

Ln calculates the natural logarithm ln (i.e loge) of a number and returns the result as a double. https://docs.mongodb.com/manual/reference/operator/aggregation/ln/

func Log

func Log(number, base interface{}) M

Log calculates the log of a number in the specified base and returns the result as a double. https://docs.mongodb.com/manual/reference/operator/aggregation/log/

func Log10

func Log10(number interface{}) M

Log10 calculates the log base 10 of a number and returns the result as a double. https://docs.mongodb.com/manual/reference/operator/aggregation/log10/

func LookupF

func LookupF(from, localField, foreignField, as string) M

LookupF perform an equality match between a field from the input documents with a field from the documents of the “joined” collection. New in version 3.2. https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/#equality-match

func LookupP

func LookupP(from string, let M, pipeline A, as string) M

LookupP perform uncorrelated subqueries between two collections as well as allow other join conditions besides a single equality match. New in version 3.2. https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/#join-conditions-and-uncorrelated-sub-queries

func Lt

func Lt(left, right interface{}) M

Lt returns true if the first value is less than the second. https://docs.mongodb.com/manual/reference/operator/aggregation/lt/

func Lte

func Lte(left, right interface{}) M

Lte returns true if the first value is less than or equal to the second. https://docs.mongodb.com/manual/reference/operator/aggregation/lte/

func Match

func Match(query interface{}) M

Match filters the document stream to allow only matching documents to pass unmodified into the next pipeline stage. $match uses standard MongoDB queries. For each input document, outputs either one document (a match) or zero documents (no match). https://docs.mongodb.com/manual/reference/operator/aggregation/match/ Match https://docs.mongodb.com/manual/reference/operator/aggregation/match

func MatchExpr

func MatchExpr(expr interface{}) M

MatchExpr is a shortcut for `{ $match: { $expr: expr } }“

func Max

func Max(expr ...interface{}) M

Max returns the maximum value. $max compares both value and type, using the specified BSON comparison order for values of different types. In MongoDB 3.2 and earlier, $max is available in the $group stage only. https://docs.mongodb.com/manual/reference/operator/aggregation/max/

func MergeObjects

func MergeObjects(expr ...interface{}) M

MergeObjects combines multiple documents into a single document. New in version 3.6. https://docs.mongodb.com/manual/reference/operator/aggregation/mergeObjects/

func Meta

func Meta(metaDataKeyword string) M

Meta access text search metadata. https://docs.mongodb.com/manual/reference/operator/aggregation/meta/

func Min

func Min(expr ...interface{}) M

Min Returns the minimum value. $min compares both value and type, using the specified BSON comparison order for values of different types. In MongoDB 3.2 and earlier, $min is available in the $group stage only. https://docs.mongodb.com/manual/reference/operator/aggregation/min/

func Mod

func Mod(dividend, divisor interface{}) M

Mod divides one number by another and returns the remainder. https://docs.mongodb.com/manual/reference/operator/aggregation/mod/

func Multiply

func Multiply(number1, number2 interface{}) M

Multiply numbers together and returns the result. https://docs.mongodb.com/manual/reference/operator/aggregation/multiply/

func Ne

func Ne(left, right interface{}) M

Ne returns true if the values are not equivalent. https://docs.mongodb.com/manual/reference/operator/aggregation/ne/

func Not

func Not(expr interface{}) M

Not returns the boolean value that is the opposite of its argument expression. https://docs.mongodb.com/manual/reference/operator/aggregation/not

func ObjectToArray

func ObjectToArray(object interface{}) M

ObjectToArray converts a document to an array of documents representing key-value pairs. https://docs.mongodb.com/manual/reference/operator/aggregation/objectToArray/

func Or

func Or(expr ...interface{}) M

Or returns true when any of its expressions evaluates to true. https://docs.mongodb.com/manual/reference/operator/aggregation/or

func Out

func Out(collection string) M

Out writes the resulting documents of the aggregation pipeline to a collection. To use the $out stage, it must be the last stage in the pipeline. https://docs.mongodb.com/manual/reference/operator/aggregation/out/

func PlanCacheStats

func PlanCacheStats() M

PlanCacheStats returns plan cache information for a collection. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/planCacheStats/

func Pow

func Pow(number, exponent interface{}) M

Pow raises a number to the specified exponent and returns the result. https://docs.mongodb.com/manual/reference/operator/aggregation/pow/

func Project

func Project(specifications interface{}) M

Project reshapes each document in the stream, such as by adding new fields or removing existing fields. For each input document, outputs one document. See also $unset for removing existing fields. https://docs.mongodb.com/manual/reference/operator/aggregation/project/

func Push

func Push(expr interface{}) M

Push Returns an array of all values that result from applying an expression to each document in a group of documents that share the same group by key. $push is only available in the $group stage. https://docs.mongodb.com/manual/reference/operator/aggregation/push/

func RadiansToDegrees

func RadiansToDegrees(number interface{}) M

RadiansToDegrees converts a value from radians to degrees. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/radiansToDegrees/

func Rand added in v0.3.2

func Rand() M

Rand returns a random float between 0 and 1 each time it is called. New in version 4.4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/rand/

func Rank added in v0.3.2

func Rank() M

Rank returns the document position (known as the rank) relative to other documents in the $setWindowFields stage partition. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/rank/

func Redact

func Redact(expr interface{}) M

Redact reshapes each document in the stream by restricting the content for each document based on information stored in the documents themselves. Incorporates the functionality of $project and $match. Can be used to implement field level redaction. For each input document, outputs either one or zero documents. https://docs.mongodb.com/manual/reference/operator/aggregation/redact/

func Reduce

func Reduce(input, initialValue, in interface{}) M

Reduce applies an expression to each element in an array and combines them into a single value. https://docs.mongodb.com/manual/reference/operator/aggregation/reduce/#exp._S_reduce

func ReplaceAll added in v0.3.2

func ReplaceAll(input, find, replacement interface{}) M

ReplaceAll replaces all instances of a search string in an input string with a replacement string. New in version 4.4. https://docs.mongodb.com/manual/reference/operator/aggregation/replaceAll/

func ReplaceOne added in v0.3.2

func ReplaceOne(input, find, replacement interface{}) M

ReplaceOne replaces the first instance of a search string in an input string with a replacement string. If no occurrences are found, $replaceOne evaluates to the input string. New in version 4.4. https://docs.mongodb.com/manual/reference/operator/aggregation/replaceOne/

func ReplaceRoot

func ReplaceRoot(newRoot interface{}) M

ReplaceRoot replaces a document with the specified embedded document. The operation replaces all existing fields in the input document, including the _id field. Specify a document embedded in the input document to promote the embedded document to the top level. $replaceWith is an alias for $replaceRoot stage. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/replaceRoot/

func ReplaceWith

func ReplaceWith(replacementDocument interface{}) M

ReplaceWith replaces a document with the specified embedded document. The operation replaces all existing fields in the input document, including the _id field. Specify a document embedded in the input document to promote the embedded document to the top level. $replaceWith is an alias for $replaceRoot stage. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/replaceWith/

func ReverseArray

func ReverseArray(array interface{}) M

ReverseArray returns an array with the elements in reverse order. https://docs.mongodb.com/manual/reference/operator/aggregation/reverseArray/

func Round

func Round(number, place interface{}) M

Round a number to to a whole integer or to a specified decimal place https://docs.mongodb.com/manual/reference/operator/aggregation/round/

func Sample

func Sample(size int) M

Sample randomly selects the specified number of documents from its input. New in version 3.2. https://docs.mongodb.com/manual/reference/operator/aggregation/sample/

func SampleRate added in v0.3.2

func SampleRate(rate float64) M

SampleRate matches a random selection of input documents. The number of documents selected approximates the sample rate expressed as a percentage of the total number of documents. New in version 4.4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/sampleRate/

func Search(args interface{}) M

Search aggregation pipleline stage performs a full-text search of the field or fields in an Atlas collection. The fields must be covered by an Atlas Search index. https://docs.mongodb.com/manual/reference/operator/aggregation/search/ https://docs.atlas.mongodb.com/atlas-search/query-syntax/

func Set

func Set(fields interface{}) M

Set Adds new fields to documents. Similar to $project, $set reshapes each document in the stream; specifically, by adding new fields to output documents that contain both the existing fields from the input documents and the newly added fields. $set is an alias for $addFields stage. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/set/

func SetDifference

func SetDifference(set1, set2 interface{}) M

SetDifference returns a set with elements that appear in the first set but not in the second set; i.e. performs a relative complement of the second set relative to the first. https://docs.mongodb.com/manual/reference/operator/aggregation/setDifference/

func SetEquals

func SetEquals(set ...interface{}) M

SetEquals returns true if the input sets have the same distinct elements. Accepts two or more argument expressions. https://docs.mongodb.com/manual/reference/operator/aggregation/setEquals/

func SetField added in v0.3.2

func SetField(field string, inputExpr interface{}, valueExpr interface{}) M

SetField adds, updates, or removes a specified field in a document. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/setField/

func SetIntersection

func SetIntersection(set ...interface{}) M

SetIntersection returns a set with elements that appear in all of the input sets. Accepts any number of argument expressions. https://docs.mongodb.com/manual/reference/operator/aggregation/setIntersection

func SetIsSubset

func SetIsSubset(set1, set2 interface{}) M

SetIsSubset returns true if all elements of the first set appear in the second set, including when the first set equals the second set; i.e. not a strict subset. https://docs.mongodb.com/manual/reference/operator/aggregation/setIsSubset/

func SetUnion

func SetUnion(set ...interface{}) M

SetUnion returns a set with elements that appear in any of the input sets. https://docs.mongodb.com/manual/reference/operator/aggregation/setUnion/

func Sin

func Sin(number interface{}) M

Sin returns the sine of a value that is measured in radians. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/sin/

func Size

func Size(array interface{}) M

Size returns the number of elements in the array. https://docs.mongodb.com/manual/reference/operator/aggregation/size/

func Skip

func Skip(n int) M

Skip the first n documents where n is the specified skip number and passes the remaining documents unmodified to the pipeline. For each input document, outputs either zero documents (for the first n documents) or one document (if after the first n documents). https://docs.mongodb.com/manual/reference/operator/aggregation/skip/

func Sort

func Sort(order interface{}) M

Sort reorders the document stream by a specified sort key. Only the order changes; the documents remain unmodified. For each input document, outputs one document. https://docs.mongodb.com/manual/reference/operator/aggregation/sort/

func SortByCount

func SortByCount(expr interface{}) M

SortByCount groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/sortByCount/

func Split

func Split(stringExpr, delimiter interface{}) M

Split a string into substrings based on a delimiter. Returns an array of substrings. If the delimiter is not found within the string, returns an array containing the original string. https://docs.mongodb.com/manual/reference/operator/aggregation/split/

func Sqrt

func Sqrt(number interface{}) M

Sqrt calculates the square root of a positive number and returns the result as a double. https://docs.mongodb.com/manual/reference/operator/aggregation/sqrt/

func StdDevPop

func StdDevPop(expr ...interface{}) M

StdDevPop returns the population standard deviation of the input values. New in version 3.2. https://docs.mongodb.com/manual/reference/operator/aggregation/stdDevPop/

func StdDevSamp

func StdDevSamp(expr ...interface{}) M

StdDevSamp returns the sample standard deviation of the input values. New in version 3.2. https://docs.mongodb.com/manual/reference/operator/aggregation/stdDevSamp/

func StrCaseCmp

func StrCaseCmp(string1, string2 interface{}) M

StrCaseCmp performs case-insensitive string comparison and returns: 0 if two strings are equivalent, 1 if the first string is greater than the second, and -1 if the first string is less than the second. https://docs.mongodb.com/manual/reference/operator/aggregation/strcasecmp/

func StrLenBytes

func StrLenBytes(stringExpr interface{}) M

StrLenBytes returns the number of UTF-8 encoded bytes in a string. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/strLenBytes/

func StrLenCP

func StrLenCP(stringExpr interface{}) M

StrLenCP returns the number of UTF-8 code points in a string. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/strLenCP/

func SubstrBytes

func SubstrBytes(stringExpr, startIndex, count interface{}) M

SubstrBytes returns the substring of a string. Starts with the character at the specified UTF-8 byte index (zero-based) in the string and continues for the specified number of bytes. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/substrBytes/

func SubstrCP

func SubstrCP(stringExpr, startIndex, count interface{}) M

SubstrCP returns the substring of a string. Starts with the character at the specified UTF-8 code point (CP) index (zero-based) in the string and continues for the number of code points specified. https://docs.mongodb.com/manual/reference/operator/aggregation/substrCP/

func Subtract

func Subtract(left, right interface{}) M

Subtract two numbers to return the difference, or two dates to return the difference in milliseconds, or a date and a number in milliseconds to return the resulting date. https://docs.mongodb.com/manual/reference/operator/aggregation/subtract/

func Sum

func Sum(expr ...interface{}) M

Sum calculates and returns the sum of numeric values. $sum ignores non-numeric values. In MongoDB 3.2 and earlier, $sum is available in the $group stage only. https://docs.mongodb.com/manual/reference/operator/aggregation/sum/

func Switch

func Switch(args ...interface{}) M

Switch evaluates a series of case expressions. When it finds an expression which evaluates to true, $switch executes a specified expression and breaks out of the control flow. Accept args as `case, then, [case, then, ..., default]`. https://docs.mongodb.com/manual/reference/operator/aggregation/switch/

func Tan

func Tan(number interface{}) M

Tan returns the tangent of a value that is measured in radians. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/tan/

func ToBool

func ToBool(expr interface{}) M

ToBool converts value to a boolean. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/toBool/

func ToDate

func ToDate(expr interface{}) M

ToDate converts a value to a date. If the value cannot be converted to a date, $toDate errors. If the value is null or missing, $toDate returns null. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/toDate/

func ToDecimal

func ToDecimal(expr interface{}) M

ToDecimal converts value to a Decimal128. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/toDecimal/

func ToDouble

func ToDouble(expr interface{}) M

ToDouble converts value to a double. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/toDouble/

func ToInt

func ToInt(expr interface{}) M

ToInt converts value to a integer. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/toInt/

func ToLong

func ToLong(expr interface{}) M

ToLong converts value to a long. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/toLong/

func ToLower

func ToLower(stringExpr interface{}) M

ToLower converts a string to lowercase. https://docs.mongodb.com/manual/reference/operator/aggregation/toLower/

func ToObjectID

func ToObjectID(expr interface{}) M

ToObjectID converts value to a ObjectId. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/toObjectId/

func ToString

func ToString(expr interface{}) M

ToString converts value to a string. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/toString/

func ToUpper

func ToUpper(stringExpr interface{}) M

ToUpper converts a string to uppercase. https://docs.mongodb.com/manual/reference/operator/aggregation/toUpper/

func Trunc

func Trunc(number, place interface{}) M

Trunc truncates a number to a whole integer or to a specified decimal place. https://docs.mongodb.com/manual/reference/operator/aggregation/trunc/

func Type

func Type(expr interface{}) M

Type return the BSON data type of the field. New in version 3.4. https://docs.mongodb.com/manual/reference/operator/aggregation/type

func UnionWith added in v0.3.2

func UnionWith(collection string, pipeline interface{}) M

UnionWith performs a union of two collections; i.e. $unionWith combines pipeline results from two collections into a single result set. The stage outputs the combined result set (including duplicates) to the next stage. New in version 4.4. https://docs.mongodb.com/manual/reference/operator/aggregation/unionWith/

func Unless

func Unless(expr M, v bool) M

Unless returns `expr if v else { $not : expr }`

func Unset

func Unset(fields ...string) M

Unset removes/excludes fields from documents. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/unset/

func UnsetField added in v0.3.2

func UnsetField(field string, inputExpr interface{}) M

UnsetField removes a specified field in a document. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/unsetField/

type MapOperator

type MapOperator M

MapOperator returned from Map

func Map

func Map(input, in interface{}) MapOperator

Map applies a subexpression to each element of an array and returns the array of resulting values in order. Accepts named parameters. https://docs.mongodb.com/manual/reference/operator/aggregation/map/

func (MapOperator) SetAs

func (op MapOperator) SetAs(v string) MapOperator

SetAs option

type MergeStage

type MergeStage M

MergeStage returned from Merge

func Merge

func Merge(into interface{}) MergeStage

Merge writes the resulting documents of the aggregation pipeline to a collection. The stage can incorporate (insert new documents, merge documents, replace documents, keep existing documents, fail the operation, process documents with a custom update pipeline) the results into an output collection. To use the $merge stage, it must be the last stage in the pipeline. New in version 4.2.

func (MergeStage) SetLet

func (stage MergeStage) SetLet(v interface{}) MergeStage

SetLet option

func (MergeStage) SetOn

func (stage MergeStage) SetOn(v interface{}) MergeStage

SetOn option

func (MergeStage) SetWhenMatched

func (stage MergeStage) SetWhenMatched(v interface{}) MergeStage

SetWhenMatched option

func (MergeStage) SetWhenNotMatched

func (stage MergeStage) SetWhenNotMatched(v interface{}) MergeStage

SetWhenNotMatched option

type MillisecondOperator

type MillisecondOperator M

MillisecondOperator returned from Millisecond

func Millisecond

func Millisecond(date interface{}) MillisecondOperator

Millisecond returns the milliseconds of a date as a number between 0 and 999. https://docs.mongodb.com/manual/reference/operator/aggregation/millisecond/

func (MillisecondOperator) SetTimezone

func (op MillisecondOperator) SetTimezone(v interface{}) MillisecondOperator

SetTimezone option New in version 3.6.

type MinuteOperator

type MinuteOperator M

MinuteOperator returned from Minute

func Minute

func Minute(date interface{}) MinuteOperator

Minute returns the minute for a date as a number between 0 and 59. https://docs.mongodb.com/manual/reference/operator/aggregation/minute/

func (MinuteOperator) SetTimezone

func (op MinuteOperator) SetTimezone(v interface{}) MinuteOperator

SetTimezone option New in version 3.6.

type MonthOperator

type MonthOperator M

MonthOperator returned from Month

func Month

func Month(date interface{}) MonthOperator

Month returns the month for a date as a number between 1 (January) and 12 (December). https://docs.mongodb.com/manual/reference/operator/aggregation/month/

func (MonthOperator) SetTimezone

func (op MonthOperator) SetTimezone(v interface{}) MonthOperator

SetTimezone option New in version 3.6.

type RTrimOperator

type RTrimOperator M

RTrimOperator returned from RTrim

func RTrim

func RTrim(input interface{}) RTrimOperator

RTrim removes whitespace or the specified characters from the end of a string. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/rtrim/

func (RTrimOperator) SetChars

func (op RTrimOperator) SetChars(expr interface{}) RTrimOperator

SetChars option

type RangeOperator

type RangeOperator M

RangeOperator returned from Range

func Range

func Range(start, end interface{}) RangeOperator

Range outputs an array containing a sequence of integer according to user-defined inputs. https://docs.mongodb.com/manual/reference/operator/aggregation/range/

func (RangeOperator) SetStep

func (op RangeOperator) SetStep(expr interface{}) RangeOperator

SetStep expression

type RegexFindAllOperator

type RegexFindAllOperator M

RegexFindAllOperator returned from RegexFindAll

func RegexFindAll

func RegexFindAll(input, regex interface{}) RegexFindAllOperator

RegexFindAll Applies a regular expression (regex) to a string and returns information on the all matched substrings. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/regexFindAll/

func (RegexFindAllOperator) SetOptions

func (op RegexFindAllOperator) SetOptions(expr interface{}) RegexFindAllOperator

SetOptions option

type RegexFindOperator

type RegexFindOperator M

RegexFindOperator returned from RegexFind

func RegexFind

func RegexFind(input, regex interface{}) RegexFindOperator

RegexFind applies a regular expression (regex) to a string and returns information on the first matched substring. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/regexFind/

func (RegexFindOperator) SetOptions

func (op RegexFindOperator) SetOptions(expr interface{}) RegexFindOperator

SetOptions option

type RegexMatchOperator

type RegexMatchOperator M

RegexMatchOperator returned from RegexMatch

func RegexMatch

func RegexMatch(input, regex interface{}) RegexMatchOperator

RegexMatch applies a regular expression (regex) to a string and returns a boolean that indicates if a match is found or not. New in version 4.2. https://docs.mongodb.com/manual/reference/operator/aggregation/regexMatch/

func (RegexMatchOperator) SetOptions

func (op RegexMatchOperator) SetOptions(expr interface{}) RegexMatchOperator

SetOptions option

type SecondOperator

type SecondOperator M

SecondOperator returned from Second

func Second

func Second(date interface{}) SecondOperator

Second returns the seconds for a date as a number between 0 and 60 (leap seconds). https://docs.mongodb.com/manual/reference/operator/aggregation/second/

func (SecondOperator) SetTimezone

func (op SecondOperator) SetTimezone(v interface{}) SecondOperator

SetTimezone option New in version 3.6.

type SetWindowFieldsStage added in v0.3.2

type SetWindowFieldsStage M

func SetWindowFields added in v0.3.2

func SetWindowFields(outputs ...SetWindowFieldsStageOutput) SetWindowFieldsStage

SetWindowFields groups documents into windows and applies one or more operators to the documents in each window. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/setWindowFields/

func (SetWindowFieldsStage) SetPartitionBy added in v0.3.2

func (stage SetWindowFieldsStage) SetPartitionBy(expression interface{}) SetWindowFieldsStage

SetPartitionBy specifies an expression to group the documents. In the $setWindowFields stage, the group of documents is known as a partition. Default is one partition for the entire collection.

func (SetWindowFieldsStage) SetSortBy added in v0.3.2

func (stage SetWindowFieldsStage) SetSortBy(sort interface{}) SetWindowFieldsStage

SetSortBy specifies the field(s) to sort the documents by in the partition. Uses the same syntax as the $sort stage. Default is no sorting.

type SetWindowFieldsStageOutput added in v0.3.2

type SetWindowFieldsStageOutput M

func SetWindowFieldsOutput added in v0.3.2

func SetWindowFieldsOutput(field string, operator M) SetWindowFieldsStageOutput

func (SetWindowFieldsStageOutput) SetDocuments added in v0.3.2

func (o SetWindowFieldsStageOutput) SetDocuments(lower, upper interface{}) SetWindowFieldsStageOutput

SetDocuments set a window where the lower and upper boundaries are specified relative to the position of the current document read from the collection.

The window boundaries are specified using a two element array containing a lower and upper limit string or integer. Use:

The "current" string for the current document position in the output. The "unbounded" string for the first or last document position in the partition. An integer for a position relative to the current document. Use a negative integer for a position before the current document. Use a positive integer for a position after the current document. 0 is the current document position.

func (SetWindowFieldsStageOutput) SetRange added in v0.3.2

func (o SetWindowFieldsStageOutput) SetRange(lower, upper interface{}) SetWindowFieldsStageOutput

SetRange set a window where the lower and upper boundaries are defined using a range of values based on the sortBy field in the current document.

The window boundaries are specified using a two element array containing a lower and upper limit string or number. Use:

The "current" string for the current document position in the output. The "unbounded" string for the first or last document position in the partition. A number to add to the value of the sortBy field for the current document. A document is in the window if the sortBy field value is inclusively within the lower and upper boundaries.

func (SetWindowFieldsStageOutput) SetUnit added in v0.3.2

type SetWindowFieldsUnit added in v0.3.2

type SetWindowFieldsUnit string
const (
	SWFUYear        SetWindowFieldsUnit = "year"
	SWFUQuarter     SetWindowFieldsUnit = "quarter"
	SWFUMonth       SetWindowFieldsUnit = "month"
	SWFUWeek        SetWindowFieldsUnit = "week"
	SWFUDay         SetWindowFieldsUnit = "day"
	SWFUHour        SetWindowFieldsUnit = "hour"
	SWFUMinute      SetWindowFieldsUnit = "minute"
	SWFUSecond      SetWindowFieldsUnit = "second"
	SWFUMillisecond SetWindowFieldsUnit = "millisecond"
)

type ShiftOperator added in v0.3.2

type ShiftOperator M

func Shift added in v0.3.2

func Shift(outputExpr interface{}, by int64) ShiftOperator

Shift returns the value from an expression applied to a document in a specified position relative to the current document in the $setWindowFields stage partition. New in version 5.0. https://docs.mongodb.com/manual/reference/operator/aggregation/shift/

func (ShiftOperator) SetDefault added in v0.3.2

func (op ShiftOperator) SetDefault(expr interface{}) ShiftOperator

type SliceOperator

type SliceOperator M

SliceOperator returned from slice

func Slice

func Slice(array, n interface{}) SliceOperator

Slice returns a subset of an array. https://docs.mongodb.com/manual/reference/operator/aggregation/slice/

func (SliceOperator) SetPos

func (op SliceOperator) SetPos(v interface{}) SliceOperator

SetPos option

type TrimOperator

type TrimOperator M

TrimOperator returned from Trim

func Trim

func Trim(input interface{}) TrimOperator

Trim removes whitespace or the specified characters from the beginning and end of a string. New in version 4.0. https://docs.mongodb.com/manual/reference/operator/aggregation/trim/

func (TrimOperator) SetChars

func (op TrimOperator) SetChars(expr interface{}) TrimOperator

SetChars option

type UnwindStage

type UnwindStage M

UnwindStage returned from Unwind

func Unwind

func Unwind(path string) UnwindStage

Unwind deconstructs an array field from the input documents to output a document for each element. Each output document replaces the array with an element value. For each input document, outputs n documents where n is the number of array elements and can be zero for an empty array. https://docs.mongodb.com/manual/reference/operator/aggregation/unwind

func (UnwindStage) SetIncludeArrayIndex

func (o UnwindStage) SetIncludeArrayIndex(v string) UnwindStage

SetIncludeArrayIndex option

func (UnwindStage) SetPreserveNullAndEmptyArrays

func (o UnwindStage) SetPreserveNullAndEmptyArrays(v bool) UnwindStage

SetPreserveNullAndEmptyArrays option https://docs.mongodb.com/manual/reference/operator/aggregation/unwind/#document-operand-with-options

type WeekOperator

type WeekOperator M

WeekOperator returned from Week

func Week

func Week(date interface{}) WeekOperator

Week returns the week of the year for a date as a number between 0 and 53. https://docs.mongodb.com/manual/reference/operator/aggregation/week/

func (WeekOperator) SetTimezone

func (op WeekOperator) SetTimezone(v interface{}) WeekOperator

SetTimezone option New in version 3.6.

type YearOperator

type YearOperator M

YearOperator returned from Year

func Year

func Year(date interface{}) YearOperator

Year returns the year for a date as a number (e.g. 2014). https://docs.mongodb.com/manual/reference/operator/aggregation/year/

func (YearOperator) SetTimezone

func (op YearOperator) SetTimezone(v interface{}) YearOperator

SetTimezone option New in version 3.6.

type ZipOperator

type ZipOperator M

ZipOperator returned from Zip

func Zip

func Zip(inputs ...interface{}) ZipOperator

Zip merge two arrays together. https://docs.mongodb.com/manual/reference/operator/aggregation/zip/

func (ZipOperator) SetDefaults

func (op ZipOperator) SetDefaults(array interface{}) ZipOperator

SetDefaults option, also set useLongestLength to true.

func (ZipOperator) SetUseLongestLength

func (op ZipOperator) SetUseLongestLength(v bool) ZipOperator

SetUseLongestLength option

Jump to

Keyboard shortcuts

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