Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AggregationMethod to Document and UnionDoc #1052

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CAPITAINMARVEL
Copy link
Contributor

@CAPITAINMARVEL CAPITAINMARVEL commented Oct 11, 2024

This PR is to allow the use of aggregation method directly after Document or UnionDoc class like the document mention in
https://beanie-odm.dev/tutorial/aggregation/

# With a search:
avg_price = await Product.find(
    Product.category.name == "Chocolate"
).avg(Product.price)

# Over the whole collection:
avg_price = await Product.avg(Product.price)

which isnt possible since Product doesnt inherit from AggregationMethod

@CAPITAINMARVEL CAPITAINMARVEL marked this pull request as draft October 14, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant