[Feature Request] `groupBy` and `aggregate` should support `include`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 15/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 2.9k
- 派生
- 157
- 平均合并
- 11 小时 42 分钟
- 30 天内合并 PR
- 20
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
zenstackhq/zenstack 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
zenstackhq/zenstack#2873 ·
维护者通常 1 天内回复
-
runtime
难度 2/5 1-3 小时 新手友好度 78/100
zenstackhq/zenstack#2868 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
zenstackhq/zenstack#2694 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
zenstackhq/zenstack#2659 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
zenstackhq/zenstack#2542 · 1 条评论 ·
维护者通常 1 天内回复
查看 zenstackhq/zenstack 的全部 Issue
相似的 Issue
-
Mondriaan
难度 1/5 1 小时以内 新手友好度 88/100
knaw-huc/textannoviz#709 ·
维护者通常 1 天内回复
-
streams:add
难度 1/5 1 小时以内 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
walletbeat/walletbeat#1558 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
hawk-digital-environments/HAWKI#438 ·
维护者通常 1 天内回复
-
good first issue
难度 2/5 1-3 小时 新手友好度 78/100
OktoLabsAI/okto-pulse#114 ·
维护者通常 1 天内回复