VianneyMI / monggregate

Library to make MongoDB aggregation framework and pipelines easy to use in python.
https://vianneymi.github.io/monggregate/
MIT License
22 stars 3 forks source link

Cannot group with more than one field name #75

Closed prusfr closed 1 year ago

prusfr commented 1 year ago

Pipeline.group() method wont' allow more than 1 field name of class string, whereas doc indicates set or list can be passed. Example : Pipeline().group(by=["field1", "field2"]) will throw an error. Thus, multi-fields group cannot be set and such a syntax : {$group: {$_id : { field1: "$field1", field2: "$field2"}}} cannot be achived

VianneyMI commented 1 year ago

Thanks for the report.

Yes the doc is a bit misleading. I am currently working on creating a proper documentation for the package. I'll fix this soon.

In the meantime you can still write:

Pipeline().group(    
        query = {
            "field1":"$field1",
            "field2":"$field2",
        }
    )
VianneyMI commented 1 year ago

Fixed in 0.16.2