diff --git a/src/monggregate/pipeline.py b/src/monggregate/pipeline.py index 7a19e78..539989f 100644 --- a/src/monggregate/pipeline.py +++ b/src/monggregate/pipeline.py @@ -315,7 +315,6 @@ def bucket(self, *, boundaries:list, by:Any=None, group_by:Any=None, default:Any self.stages.append( Bucket( by = by or group_by, - #group_by = group_by or by, boundaries = boundaries, default = default, output = output @@ -372,7 +371,6 @@ def bucket_auto(self, *, by:Any=None, group_by:Any=None, buckets:int, output:dic self.stages.append( BucketAuto( by = by or group_by, - #group_by = group_by, buckets = buckets, output = output, granularity = granularity @@ -438,9 +436,9 @@ def explode(self, \ self.stages.append( Unwind( - path=path, + path_to_array=path_to_array or path, include_array_index=include_array_index, - always=always + always=always or preserve_null_and_empty_arrays ) ) return self @@ -453,7 +451,7 @@ def group(self, *, by:Any|None=None, _id:Any|None=None, query:dict={})->Self: Arguments: ------------------------ - - by, str | list[str] | set[str] | dict | None : field or group of fields to group by + - by (_id), str | list[str] | set[str] | dict | None : field or group of fields to group by - query, dict | None : Computed aggregated values (per group) Online MongoDB documentation: @@ -475,7 +473,7 @@ def group(self, *, by:Any|None=None, _id:Any|None=None, query:dict={})->Self: self.stages.append( Group( - by=by, + by=by or _id, query=query ) ) @@ -568,9 +566,9 @@ def lookup(self, *, \ Lookup( right = right, on = on, - left_on = left_on, - right_on = right_on, - name =name + left_on = left_on or local_field, + right_on = right_on or foreign_field, + name = name ) ) return self @@ -713,7 +711,10 @@ def match(self, query:dict={}, expression:Any=None, **kwargs:Any)->Self: query = query | kwargs self.stages.append( - Match(query=query, expression=expression) + Match( + query=query, + expression=expression + ) ) return self @@ -797,7 +798,7 @@ def replace_root(self, path:str|None=None, path_to_new_root:str|None=None, *,doc ------------------------------------- - statement, dict : the statement generated during instantiation after parsing the other arguments - - path_to_new_root, str|None : the path to the embedded document to be promoted + - path_to_new_root (path), str|None : the path to the embedded document to be promoted - document, dict|None : document being created and to be set as the new root or expression Online MongoDB documentation: @@ -814,7 +815,10 @@ def replace_root(self, path:str|None=None, path_to_new_root:str|None=None, *,doc """ self.stages.append( - ReplaceRoot(path=path, document=document) + ReplaceRoot( + path=path or path_to_new_root, + document=document + ) ) return self @@ -826,7 +830,7 @@ def replace_with(self, path:str|None=None, path_to_new_root:str|None=None, *,doc ------------------------------------- - statement, dict : the statement generated during instantiation after parsing the other arguments - - path_to_new_root, str|None : the path to the embedded document to be promoted + - path_to_new_root (path), str|None : the path to the embedded document to be promoted - document, dict|None : document being created and to be set as the new root or expression Online MongoDB documentation: @@ -843,7 +847,10 @@ def replace_with(self, path:str|None=None, path_to_new_root:str|None=None, *,doc """ self.stages.append( - ReplaceRoot(path=path, document=document) + ReplaceRoot( + path=path or path_to_new_root, + document=document + ) ) return self @@ -1376,7 +1383,9 @@ def union_with(self, collection:str, coll:str, pipeline:list[dict]|None=None)->S """ self.stages.append( - UnionWith(collection=collection, pipeline=pipeline) + UnionWith( + collection=collection or coll, + pipeline=pipeline) ) return self diff --git a/src/monggregate/stages/group.py b/src/monggregate/stages/group.py index 5e86587..4c51ad4 100644 --- a/src/monggregate/stages/group.py +++ b/src/monggregate/stages/group.py @@ -74,7 +74,7 @@ class Group(Stage): Attributes: ----------- - - by, str | list[str] | set[str] | dict | None : field or group of fields to group by + - by (_id), str | list[str] | set[str] | dict | None : field or group of fields to group by - query, dict | None : Computed aggregated values (per group) Online MongoDB documentation: diff --git a/src/monggregate/stages/replace_root.py b/src/monggregate/stages/replace_root.py index 2b08c97..3b70356 100644 --- a/src/monggregate/stages/replace_root.py +++ b/src/monggregate/stages/replace_root.py @@ -77,7 +77,7 @@ class ReplaceRoot(Stage): ----------- - statement, dict : the statement generated during instantiation after parsing the other arguments - - path_to_new_root, str|None : the path to the embedded document to be promoted + - path_to_new_root (path), str|None : the path to the embedded document to be promoted - document, dict|None : document being created and to be set as the new root or expression Online MongoDB documentation: