AccumulatedGroupExpression

public enum AccumulatedGroupExpression

All Accumulated Group Expressions used for the group aggregation stage

  • Returns the value that results from applying an expression to the first document in a group of documents.

    When a field is selected, the first Document’s value at this key will be used.

    Declaration

    Swift

    case first(ExpressionRepresentable)
  • Returns the value that results from applying an expression to the last document in a group of documents.

    When a field is selected, the last Document’s value at this key will be used.

    Declaration

    Swift

    case last(ExpressionRepresentable)
  • Creates a sum expression. Can contain one or more values.

    The result of this operator is the sum of all provided resulting values (when multiple are entered).

    All results must be numbers

    When a single expression is provided it will be regarded as a literal rather than an array and is useful when providing a selector for a field.

    When multiple expressions are provided this will be regarded as an array of expressions resulting in a number.

    Declaration

    Swift

    public static func sumOf(_ expressions: ExpressionRepresentable...) -> AccumulatedGroupExpression
  • Creates a sum expression. Can contain one or more values.

    The result of this operator is the sum of all provided resulting values (when multiple are entered).

    All results must be numbers

    When a single expression is provided it will be regarded as a literal rather than an array and is useful when providing a selector for a field.

    When multiple expressions are provided this will be regarded as an array of expressions resulting in a number.

    Declaration

    Swift

    public static func sumOf(_ expressions: [ExpressionRepresentable]) -> AccumulatedGroupExpression
  • Creates a avg expression. Can contain one or more values.

    The result of this operator is the average of all provided resulting values (when multiple are entered).

    All results must be numbers

    When a single expression is provided it will be regarded as a literal rather than an array and is useful when providing a selector for a field.

    When multiple expressions are provided this will be regarded as an array of expressions resulting in a number.

    Declaration

    Swift

    public static func averageOf(_ expressions: ExpressionRepresentable...) -> AccumulatedGroupExpression
  • Creates a avg expression. Can contain one or more values.

    The result of this operator is the average of all provided resulting values (when multiple are entered).

    All results must be numbers

    When a single expression is provided it will be regarded as a literal rather than an array and is useful when providing a selector for a field.

    When multiple expressions are provided this will be regarded as an array of expressions resulting in a number.

    Declaration

    Swift

    public static func averageOf(_ expressions: [ExpressionRepresentable]) -> AccumulatedGroupExpression
  • Creates a min expression. Can contain one or more values.

    The result of this operator is the smallest number amongst all provided resulting values (when multiple are entered).

    All results must be numbers

    When a single expression is provided it will be regarded as a literal rather than an array and is useful when providing a selector for a field.

    When multiple expressions are provided this will be regarded as an array of expressions resulting in a number.

    Declaration

    Swift

    public static func minOf(_ expressions: ExpressionRepresentable...) -> AccumulatedGroupExpression
  • Creates a min expression. Can contain one or more values.

    The result of this operator is the smallest number amongst all provided resulting values (when multiple are entered).

    All results must be numbers

    When a single expression is provided it will be regarded as a literal rather than an array and is useful when providing a selector for a field.

    When multiple expressions are provided this will be regarded as an array of

    Declaration

    Swift

    public static func minOf(_ expressions: [ExpressionRepresentable]) -> AccumulatedGroupExpression
  • Creates a max expression. Can contain one or more values.

    The result of this operator is the biggest number amongst all provided resulting values (when multiple are entered).

    All results must be numbers

    When a single expression is provided it will be regarded as a literal rather than an array and is useful when providing a selector for a field.

    When multiple expressions are provided this will be regarded as an array of

    Declaration

    Swift

    public static func maxOf(_ expressions: ExpressionRepresentable...) -> AccumulatedGroupExpression
  • Creates a max expression. Can contain one or more values.

    The result of this operator is the biggest number amongst all provided resulting values (when multiple are entered).

    All results must be numbers

    When a single expression is provided it will be regarded as a literal rather than an array and is useful when providing a selector for a field.

    When multiple expressions are provided this will be regarded as an array of

    Declaration

    Swift

    public static func maxOf(_ expressions: [ExpressionRepresentable]) -> AccumulatedGroupExpression
  • Converts this AccumulatedGroupExpression to a BSON.Primitive so that it can be embedded inside a Document easily

    Declaration

    Swift

    public func makePrimitive() -> BSON.Primitive
  • Converts this AccumulatedGroupExpression to a Document operator for MongoDB

    Declaration

    Swift

    public func makeDocument() -> Document