S

Loading…

Type Alias

GroupAccumulator

What a $group stage computes for each group. Each is an object with one key.

  • { $count: {} } the number of documents in the group.
  • { $sum: value } the total of the numbers. Values that are not numbers are ignored, and the total is 0 when there are none. A group may add numbers or bigint values, not both, and a bigint total must stay within the signed 64-bit range.
  • { $avg: value } the mean of the numbers, or null when there are none. Values that are not numbers are ignored. It does not accept bigint values.
  • { $min: value } and { $max: value } the smallest and largest value by the sort order of the query semantics, ignoring documents that lack the field. null when no document has it.
  • { $first: value } and { $last: value } the value from the first or last document of the group in the order the documents arrived, or null when that document lacks the field.
type GroupAccumulator =
  | { readonly $count: Readonly<Record<string, never>> }
  | { readonly $sum: GroupValue }
  | { readonly $avg: GroupValue }
  | { readonly $min: GroupValue }
  | { readonly $max: GroupValue }
  | { readonly $first: GroupValue }
  | { readonly $last: GroupValue }

Defined in packages/driver/src/aggregation.ts:86

Used by#