Class ScriptOperators.Accumulator

java.lang.Object
org.springframework.data.mongodb.core.aggregation.ScriptOperators.Accumulator
All Implemented Interfaces:
AggregationExpression, MongoExpression
Enclosing class:
ScriptOperators

public static class ScriptOperators.Accumulator extends Object
ScriptOperators.Accumulator defines a custom aggregation $accumulator operator, one that maintains its state (e.g. totals, maximums, minimums, and related data) as documents progress through the pipeline, in JavaScript.
{ $accumulator: { init: ..., intArgs: ..., accumulate: ..., accumulateArgs: ..., merge: ..., finalize: ..., lang: "js" } }
ScriptOperators.Accumulator can be used as part of $group, $bucket and $bucketAuto pipeline stages.
NOTE: Server-Side JavaScript execution must be enabled
See Also:
  • Method Details

    • getMongoMethod

      protected String getMongoMethod()
    • toDocument

      public org.bson.Document toDocument(AggregationOperationContext context)
      Description copied from interface: AggregationExpression
      Turns the AggregationExpression into a Document within the given AggregationOperationContext.
      Specified by:
      toDocument in interface AggregationExpression
      Parameters:
      context - must not be null.
      Returns:
      the MongoDB native (Document) form of the expression.
    • toDocument

      public org.bson.Document toDocument(Object value, AggregationOperationContext context)
    • asFields

      protected static List<Field> asFields(String... fieldRefs)
    • append

      protected List<Object> append(Object value, org.springframework.data.mongodb.core.aggregation.AbstractAggregationExpression.Expand expandList)
    • append

      protected List<Object> append(Object value)
    • append

      protected Map<String,Object> append(String key, Object value)
    • appendTo

      protected Map<String,Object> appendTo(String key, Object value)
    • remove

      protected Map<String,Object> remove(String key)
    • appendAt

      protected Map<String,Object> appendAt(int index, String key, Object value)
      Append the given key at the position in the underlying LinkedHashMap.
      Parameters:
      index -
      key -
      value -
      Returns:
      Since:
      3.1
    • values

      protected List<Object> values()
    • get

      protected <T> T get(int index)
      Get the value at a given index.
      Type Parameters:
      T -
      Parameters:
      index -
      Returns:
      Since:
      2.1
    • get

      protected <T> T get(Object key)
      Get the value for a given key.
      Type Parameters:
      T -
      Parameters:
      key -
      Returns:
      Since:
      2.1
    • isArgumentMap

      protected boolean isArgumentMap()
    • argumentMap

      protected Map<String,Object> argumentMap()
      Get the argument map.
      Returns:
      Since:
      2.1
    • contains

      protected boolean contains(Object key)
      Check if the given key is available.
      Parameters:
      key -
      Returns:
      Since:
      2.1