[Feature Request] `groupBy` and `aggregate` should support `include`
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 15/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
Hướng nghiên cứu
The issue points to no files, so begin at the query engine that compiles groupBy/aggregate calls and compare it with how include is resolved for find queries; that pairing shows where join logic would be added. Then read the policy-enforcement layer to see how include results are filtered, since the request requires access policies to be respected. Done means groupBy/aggregate accept include, related fields come back in the result, and tests cover both policy-restricted and unrestricted joins.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
When using the query API groupBy and aggregate currently operate only on fields of the base model. There is no way to join related models using include or similar semantics. This becomes a problem when aggregating records by a value that lives on a related table and is not the primary key. In practice this means I can group by a foreign key id but then must perform an additional query to resolve meaningful fields like a symbol or code from the related table, which adds extra round trips and complexity.
Describe the solution you'd like
Extend groupBy and aggregate to support include so that related models can be joined as part of the aggregation query. This would allow grouping or aggregating based on fields from related tables and returning those related fields directly in the result set. Conceptually this would mirror how include works for find queries while still respecting ZenStack access policies.
Describe alternatives you've considered
The main workaround is to group by the foreign key id and then issue a second query to fetch the related records and manually merge the results. Another option is denormalizing the related field into the base table, but that introduces duplication and consistency issues. Neither approach is ideal compared to first class join support in groupBy and aggregate.
Additional context
This feature would help reduce query count and improve performance for reporting and analytics style use cases. It would also bring groupBy and aggregate closer in parity with common ORM and SQL patterns where joins are available during aggregation.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.9k
- Fork
- 157
- Merge trung bình
- 11 giờ 42 phút
- Pull request đã merge (30 ngày)
- 20
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của zenstackhq/zenstack
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
zenstackhq/zenstack#2873 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
runtime
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
zenstackhq/zenstack#2868 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
zenstackhq/zenstack#2694 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
zenstackhq/zenstack#2659 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
zenstackhq/zenstack#2542 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của zenstackhq/zenstack
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
answerLoops/answerLoops#345 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
siyuan-note/siyuan#20313 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
LanternOps/breeze#8254 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
gofish-graphics/gofish-graphics#1084 ·
Maintainer thường phản hồi trong vòng 1 ngày