mongodb-odm icon indicating copy to clipboard operation
mongodb-odm copied to clipboard

Allow flexible result mapping for aggregation pipelines

Open alcaeus opened this issue 6 years ago • 0 comments

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

When using aggregation pipelines in ODM, users can use QueryResultDocument objects to hydrate aggregation results into objects. However, when using more complex pipelines, this can quickly lead to issues. For example, https://github.com/api-platform/core/pull/2144#issuecomment-414065397 shows using a facet pipeline stage to simultaneously fetch results and the count from a collection at the same time. However, this can only be done with arrays and a separate iterator because dynamically mapping the aggregation result to an object is not possible.

The idea is to create a system similar to ORM's ResultSetMapping that allows for more flexible and dynamic mapping of aggregation pipeline results.

alcaeus avatar Nov 25 '18 08:11 alcaeus