Accumulator

Companion
class
class Object
trait Matchable
class Any

Value members

Concrete methods

def addToSet[T](fieldName: String, expression: T): Accumulator
def apply(fieldName: String, initFunction: String, accumulateFunction: String, mergeFunction: String, initArgs: List[String], accumulateArgs: List[String], finalizeFunction: Option[String], lang: String): Accumulator

Creates an $accumulator pipeline stage

Creates an $accumulator pipeline stage

Value Params
accumulateArgs

additional accumulate function’s arguments. The first argument to the function is ‘state’.

accumulateFunction

a function used to accumulate documents

fieldName

the field name

finalizeFunction

a function used to finalize the state and return the result

initArgs

init function’s arguments

initFunction

a function used to initialize the state

lang

a language specifier

mergeFunction

a function used to merge two internal states, e.g. accumulated on different shards or threads. It returns the resulting state of the accumulator.

Returns

the $accumulator pipeline stage https://docs.mongodb.com/manual/reference/operator/aggregation/accumulator/

Since

4.1

def avg[T](fieldName: String, expression: T): Accumulator
def first[T](fieldName: String, expression: T): Accumulator
def last[T](fieldName: String, expression: T): Accumulator
def max[T](fieldName: String, expression: T): Accumulator
def min[T](fieldName: String, expression: T): Accumulator
def push[T](fieldName: String, expression: T): Accumulator
def stdDevPop[T](fieldName: String, expression: T): Accumulator
def stdDevSamp[T](fieldName: String, expression: T): Accumulator
def sum[T](fieldName: String, expression: T): Accumulator