art049 / odmantic

Sync and Async ODM (Object Document Mapper) for MongoDB based on python type hints
http://art049.github.io/odmantic
ISC License
1.05k stars 92 forks source link

Aggregation support via the find method #414

Open EllieSapir opened 7 months ago

EllieSapir commented 7 months ago

Feature request

Context

engine.find allows full flexibility to query anything matching the read operation query syntax, via the *queries parameter, by allowing to pass QueryExpression along raw queries (dicts).

engine.find uses collection.aggregate internally, and therefore can allow an equal flexibility to use any aggregation stage matching the aggregation pipeline syntax

But, the function limits the use of aggregation stages to the ones defined explicitly via the function parameters: limit, sort, skip - for the $limit, $skip and $sort aggregation stages. And *queries - which are used inside the $match aggregation stage.

Solution

Alternative solutions

Implement the db.collection.find() method in engine.find, and create an engine.aggregate method for aggregations related operations.

Additional context

This will allow the user to use implemented odemantic functions for aggregation, reducing the need to use Raw query helpers

EllieSapir commented 7 months ago

I would like to contribute this feature, can you assign it to me?

z0z0r4 commented 2 months ago

Agreed! I need it