SetWindowFields constructor

SetWindowFields({
  1. dynamic partitionBy,
  2. Map<String, int>? sortBy,
  3. dynamic defaultId,
  4. required dynamic output,
})

Creates $setWindowFields aggregation stage

  • partitionBy Optional - 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.
  • sortBy Required for some operators Specifies the field(s) to sort the documents by in the partition. Uses the same syntax as the $sort stage. Default is no sorting.
  • output - Specifies the field(s) an related parameters to append to the documents in the output returned by the $setWindowFields stage. Each field is set to the result returned by the window operator. The field can either an Output object, a list of Output Objects or a document containing the explicit description of the output required

Implementation

SetWindowFields({
  partitionBy,
  Map<String, int>? sortBy,
  defaultId,
  required dynamic output,
}) : super(
          stSetWindowFields,
          AEObject({
            if (partitionBy != null) spPartitionBy: partitionBy,
            if (sortBy != null) spSortBy: AEObject(sortBy),
            'output': _getOutputDocument(output),
          }));