Packages

o

org.mongodb.scala.model

Accumulators

object Accumulators

Builders for accumulators used in the group pipeline stage of an aggregation pipeline.

Since

1.0

See also

Aggregation pipeline

Accumulators

Expressions

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Accumulators
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def accumulator(fieldName: String, initFunction: String, initArgs: Seq[String], accumulateFunction: String, accumulateArgs: Seq[String], mergeFunction: String, finalizeFunction: String, lang: String): BsonField

    Creates an $accumulator pipeline stage

    Creates an $accumulator pipeline stage

    fieldName

    the field name

    initFunction

    a function used to initialize the state

    initArgs

    init function’s arguments (may be null)

    accumulateFunction

    a function used to accumulate documents

    accumulateArgs

    additional accumulate function’s arguments (may be null). The first argument to the function is ‘state’.

    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.

    finalizeFunction

    a function used to finalize the state and return the result (may be null)

    lang

    a language specifier

    returns

    the $accumulator pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 4.4 or greater

    See also

    $accumulator

  5. def accumulator(fieldName: String, initFunction: String, initArgs: Seq[String], accumulateFunction: String, accumulateArgs: Seq[String], mergeFunction: String, finalizeFunction: String): BsonField

    Creates an $accumulator pipeline stage

    Creates an $accumulator pipeline stage

    fieldName

    the field name

    initFunction

    a function used to initialize the state

    initArgs

    init function’s arguments (may be null)

    accumulateFunction

    a function used to accumulate documents

    accumulateArgs

    additional accumulate function’s arguments (may be null). The first argument to the function is ‘state’.

    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.

    finalizeFunction

    a function used to finalize the state and return the result (may be null)

    returns

    the $accumulator pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 4.4 or greater

    See also

    $accumulator

  6. def accumulator(fieldName: String, initFunction: String, accumulateFunction: String, mergeFunction: String, finalizeFunction: String): BsonField

    Creates an $accumulator pipeline stage

    Creates an $accumulator pipeline stage

    fieldName

    the field name

    initFunction

    a function used to initialize the state

    accumulateFunction

    a function used to accumulate documents

    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.

    finalizeFunction

    a function used to finalize the state and return the result (may be null)

    returns

    the $accumulator pipeline stage

    Since

    1.2

    Note

    Requires MongoDB 4.4 or greater

    See also

    $accumulator

  7. def accumulator(fieldName: String, initFunction: String, accumulateFunction: String, mergeFunction: String): BsonField

    Creates an $accumulator pipeline stage

    Creates an $accumulator pipeline stage

    fieldName

    the field name

    initFunction

    a function used to initialize the state

    accumulateFunction

    a function used to accumulate documents

    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

    Since

    1.2

    Note

    Requires MongoDB 4.4 or greater

    See also

    $accumulator

  8. def addToSet[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing all unique values that results from applying the given expression to each document in a group of documents that share the same group by key.

    Gets a field name for a $group operation representing all unique values that results from applying the given expression to each document in a group of documents that share the same group by key.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    See also

    $addToSet

  9. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  10. def avg[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing the average of the values of the given expression when applied to all members of the group.

    Gets a field name for a $group operation representing the average of the values of the given expression when applied to all members of the group.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    See also

    $avg

  11. def bottom[OutExpression](fieldName: String, sortBy: Bson, outExpression: OutExpression): BsonField

    Returns a combination of a computed field and an accumulator that produces a value of the given outExpression computed for the bottom element within a group sorted according to the provided sort specification.

    Returns a combination of a computed field and an accumulator that produces a value of the given outExpression computed for the bottom element within a group sorted according to the provided sort specification.

    OutExpression

    The type of the output expression.

    fieldName

    The field computed by the accumulator.

    sortBy

    The sort specification. The syntax is identical to the one expected by Aggregates.sort.

    outExpression

    The output expression.

    returns

    The requested BsonField.

    Since

    4.7

    Note

    Requires MongoDB 5.2 or greater

    See also

    $bottom

  12. def bottomN[OutExpression, NExpression](fieldName: String, sortBy: Bson, outExpression: OutExpression, nExpression: NExpression): BsonField

    Returns a combination of a computed field and an accumulator that produces a BSON Array of values of the given outExpression computed for the bottom N elements within a group sorted according to the provided sort specification, where N is the positive integral value of the nExpression.

    Returns a combination of a computed field and an accumulator that produces a BSON Array of values of the given outExpression computed for the bottom N elements within a group sorted according to the provided sort specification, where N is the positive integral value of the nExpression.

    OutExpression

    The type of the output expression.

    NExpression

    The type of the limiting expression.

    fieldName

    The field computed by the accumulator.

    sortBy

    The sort specification. The syntax is identical to the one expected by Aggregates.sort.

    outExpression

    The output expression.

    nExpression

    The expression limiting the number of produced values.

    returns

    The requested BsonField.

    Since

    4.7

    Note

    Requires MongoDB 5.2 or greater

    See also

    $bottomN

  13. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  14. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  16. def first[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing the value of the given expression when applied to the first member of the group.

    Gets a field name for a $group operation representing the value of the given expression when applied to the first member of the group.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    See also

    $first

  17. def firstN[InExpression, NExpression](fieldName: String, inExpression: InExpression, nExpression: NExpression): BsonField

    Returns a combination of a computed field and an accumulator that produces a BSON Array of values of the given inExpression computed for the first N elements within a presorted group, where N is the positive integral value of the nExpression.

    Returns a combination of a computed field and an accumulator that produces a BSON Array of values of the given inExpression computed for the first N elements within a presorted group, where N is the positive integral value of the nExpression.

    InExpression

    The type of the input expression.

    NExpression

    The type of the limiting expression.

    fieldName

    The field computed by the accumulator.

    inExpression

    The input expression.

    nExpression

    The expression limiting the number of produced values.

    returns

    The requested BsonField.

    Since

    4.7

    Note

    Requires MongoDB 5.2 or greater

    See also

    $firstN

  18. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  19. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  20. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  21. def last[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing the value of the given expression when applied to the last member of the group.

    Gets a field name for a $group operation representing the value of the given expression when applied to the last member of the group.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    See also

    $last

  22. def lastN[InExpression, NExpression](fieldName: String, inExpression: InExpression, nExpression: NExpression): BsonField

    Returns a combination of a computed field and an accumulator that produces a BSON Array of values of the given inExpression computed for the last N elements within a presorted group where N is the positive integral value of the nExpression.

    Returns a combination of a computed field and an accumulator that produces a BSON Array of values of the given inExpression computed for the last N elements within a presorted group where N is the positive integral value of the nExpression.

    InExpression

    The type of the input expression.

    NExpression

    The type of the limiting expression.

    fieldName

    The field computed by the accumulator.

    inExpression

    The input expression.

    nExpression

    The expression limiting the number of produced values.

    returns

    The requested BsonField.

    Since

    4.7

    Note

    Requires MongoDB 5.2 or greater

    See also

    $lastN

  23. def max[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing the maximum of the values of the given expression when applied to all members of the group.

    Gets a field name for a $group operation representing the maximum of the values of the given expression when applied to all members of the group.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    See also

    $max

  24. def maxN[InExpression, NExpression](fieldName: String, inExpression: InExpression, nExpression: NExpression): BsonField

    Returns a combination of a computed field and an accumulator that produces a BSON Array of N largest values of the given inExpression, where N is the positive integral value of the nExpression.

    Returns a combination of a computed field and an accumulator that produces a BSON Array of N largest values of the given inExpression, where N is the positive integral value of the nExpression.

    InExpression

    The type of the input expression.

    NExpression

    The type of the limiting expression.

    fieldName

    The field computed by the accumulator.

    inExpression

    The input expression.

    nExpression

    The expression limiting the number of produced values.

    returns

    The requested BsonField.

    Since

    4.7

    Note

    Requires MongoDB 5.2 or greater

    See also

    $maxN

  25. def median[InExpression](fieldName: String, inExpression: InExpression, method: QuantileMethod): BsonField

    Returns a combination of a computed field and an accumulator that generates a BSON Double representing the median value computed from the given nExpression within a group.

    Returns a combination of a computed field and an accumulator that generates a BSON Double representing the median value computed from the given nExpression within a group.

    InExpression

    The type of the input expression.

    fieldName

    The field computed by the accumulator.

    inExpression

    The input expression.

    method

    The method to be used for computing the median.

    returns

    The requested BsonField.

    Since

    4.10

    Note

    Requires MongoDB 7.0 or greater

    See also

    $median

  26. def mergeObjects[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing the result of merging the fields of the documents.

    Gets a field name for a $group operation representing the result of merging the fields of the documents. If documents to merge include the same field name, the field, in the resulting document, has the value from the last document merged for the field.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    Since

    4.4

    See also

    $mergeObjects

  27. def min[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing the minimum of the values of the given expression when applied to all members of the group.

    Gets a field name for a $group operation representing the minimum of the values of the given expression when applied to all members of the group.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    See also

    $min

  28. def minN[InExpression, NExpression](fieldName: String, inExpression: InExpression, nExpression: NExpression): BsonField

    Returns a combination of a computed field and an accumulator that produces a BSON Array of N smallest values of the given inExpression, where N is the positive integral value of the nExpression.

    Returns a combination of a computed field and an accumulator that produces a BSON Array of N smallest values of the given inExpression, where N is the positive integral value of the nExpression.

    InExpression

    The type of the input expression.

    NExpression

    The type of the limiting expression.

    fieldName

    The field computed by the accumulator.

    inExpression

    The input expression.

    nExpression

    The expression limiting the number of produced values.

    returns

    The requested BsonField.

    Since

    4.7

    Note

    Requires MongoDB 5.2 or greater

    See also

    $minN

  29. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  30. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  31. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  32. def percentile[InExpression, PExpression](fieldName: String, inExpression: InExpression, pExpression: PExpression, method: QuantileMethod): BsonField

    Returns a combination of a computed field and an accumulator that generates a BSON ARRAY containing computed values from the given inExpression based on the provided pExpression, which represents an array of percentiles of interest within a group, where each element is a numeric value between 0.0 and 1.0 (inclusive).

    Returns a combination of a computed field and an accumulator that generates a BSON ARRAY containing computed values from the given inExpression based on the provided pExpression, which represents an array of percentiles of interest within a group, where each element is a numeric value between 0.0 and 1.0 (inclusive).

    InExpression

    The type of the input expression.

    PExpression

    The type of the percentile expression.

    fieldName

    The field computed by the accumulator.

    inExpression

    The input expression.

    pExpression

    The expression representing a percentiles of interest.

    method

    The method to be used for computing the percentiles.

    returns

    The requested BsonField.

    Since

    4.10

    Note

    Requires MongoDB 7.0 or greater

    See also

    $percentile

  33. def push[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing an array of all values that results from applying an expression to each document in a group of documents that share the same group by key.

    Gets a field name for a $group operation representing an array of all values that results from applying an expression to each document in a group of documents that share the same group by key.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    See also

    $push

  34. def stdDevPop[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing the sample standard deviation of the values of the given expression when applied to all members of the group.

    Gets a field name for a $group operation representing the sample standard deviation of the values of the given expression when applied to all members of the group.

    Use if the values encompass the entire population of data you want to represent and do not wish to generalize about a larger population.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    Since

    1.1

    Note

    Requires MongoDB 3.2 or greater

    See also

    $stdDevPop

  35. def stdDevSamp[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing the sample standard deviation of the values of the given expression when applied to all members of the group.

    Gets a field name for a $group operation representing the sample standard deviation of the values of the given expression when applied to all members of the group.

    Use if the values encompass a sample of a population of data from which to generalize about the population.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    Since

    1.1

    Note

    Requires MongoDB 3.2 or greater

    See also

    $stdDevSamp

  36. def sum[TExpression](fieldName: String, expression: TExpression): BsonField

    Gets a field name for a $group operation representing the sum of the values of the given expression when applied to all members of the group.

    Gets a field name for a $group operation representing the sum of the values of the given expression when applied to all members of the group.

    TExpression

    the expression type

    fieldName

    the field name

    expression

    the expression

    returns

    the field

    See also

    $sum

  37. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  38. def toString(): String
    Definition Classes
    AnyRef → Any
  39. def top[OutExpression](fieldName: String, sortBy: Bson, outExpression: OutExpression): BsonField

    Returns a combination of a computed field and an accumulator that produces a value of the given outExpression computed for the top element within a group sorted according to the provided sort specification.

    Returns a combination of a computed field and an accumulator that produces a value of the given outExpression computed for the top element within a group sorted according to the provided sort specification.

    OutExpression

    The type of the output expression.

    fieldName

    The field computed by the accumulator.

    sortBy

    The sort specification. The syntax is identical to the one expected by Aggregates.sort.

    outExpression

    The output expression.

    returns

    The requested BsonField.

    Since

    4.7

    Note

    Requires MongoDB 5.2 or greater

    See also

    $topN

  40. def topN[OutExpression, NExpression](fieldName: String, sortBy: Bson, outExpression: OutExpression, nExpression: NExpression): BsonField

    Returns a combination of a computed field and an accumulator that produces a BSON Array of values of the given outExpression computed for the top N elements within a group sorted according to the provided sort specification, where N is the positive integral value of the nExpression.

    Returns a combination of a computed field and an accumulator that produces a BSON Array of values of the given outExpression computed for the top N elements within a group sorted according to the provided sort specification, where N is the positive integral value of the nExpression.

    OutExpression

    The type of the output expression.

    NExpression

    The type of the limiting expression.

    fieldName

    The field computed by the accumulator.

    sortBy

    The sort specification. The syntax is identical to the one expected by Aggregates.sort.

    outExpression

    The output expression.

    nExpression

    The expression limiting the number of produced values.

    returns

    The requested BsonField.

    Since

    4.7

    Note

    Requires MongoDB 5.2 or greater

    See also

    $topN

  41. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  42. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  43. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped