motorhead.aggregation
AggregationStage = Literal['$addFields', '$bucket', '$bucketAuto', '$changeStream', '$changeStreamSplitLargeEvent', '$collStats', '$count', '$currentOp', '$densify', '$documents', '$facet', '$fill', '$geoNear', '$graphLookup', '$group', '$indexStats', '$limit', '$listLocalSessions', '$listSampledQueries', '$listSearchIndexes', '$listSessions', '$lookup', '$match', '$merge', '$out', '$planCacheStats', '$project', '$querySettings', '$redact', '$replaceRoot', '$replaceWith', '$sample', '$search', '$searchMeta', '$set', '$setWindowFields', '$shardedDataDistribution', '$skip', '$sort', '$sortByCount', '$unionWith', '$unset', '$unwind', '$vectorSearch']
module-attribute
Aggregation pipeline stage.
Aggregation
Bases: list[dict[str, AggregationData]]
Aggregation pipeline.
Source code in motorhead/aggregation.py
__init__(stages=())
Initialization.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stages
|
Iterable[AggregationData]
|
The aggregation pipeline stages. |
()
|
stage(stage, value)
Adds the stage to the aggregation pipeline.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage
|
AggregationStage
|
The stage operator. |
required |
value
|
AggregationData | Clause
|
The stage operator's content. |
required |
Returns:
Type | Description |
---|---|
Self
|
The aggregation pipeline. |
Source code in motorhead/aggregation.py
make_aggregation_stage(stage, value)
Creates an aggregation pipeline stage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage
|
AggregationStage
|
The stage operator. |
required |
value
|
AggregationData | Clause
|
The stage operator's content. |
required |
Returns:
Type | Description |
---|---|
dict[str, AggregationData]
|
The aggregation pipeline stage. |