Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Feature Request] `groupBy` and `aggregate` should support `include`

Đang mở
#2,366 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

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
Lĩnh vực
api, backend

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của zenstackhq/zenstack

Tất cả issue của zenstackhq/zenstack

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.