()
| 4034 | |
| 4035 | describe(`nested aggregate: count comments per issue (as toArray)`, () => { |
| 4036 | function buildNestedAggregateToArrayQuery() { |
| 4037 | return createLiveQueryCollection((q) => |
| 4038 | q.from({ p: projects }).select(({ p }) => ({ |
| 4039 | id: p.id, |
| 4040 | name: p.name, |
| 4041 | issues: q |
| 4042 | .from({ i: issues }) |
| 4043 | .where(({ i }) => eq(i.projectId, p.id)) |
| 4044 | .select(({ i }) => ({ |
| 4045 | id: i.id, |
| 4046 | title: i.title, |
| 4047 | commentCount: toArray( |
| 4048 | q |
| 4049 | .from({ c: comments }) |
| 4050 | .where(({ c }) => eq(c.issueId, i.id)) |
| 4051 | .select(({ c }) => ({ total: count(c.id) })), |
| 4052 | ), |
| 4053 | })), |
| 4054 | })), |
| 4055 | ) |
| 4056 | } |
| 4057 | |
| 4058 | it(`each issue gets its own comment count as an array`, async () => { |
| 4059 | const collection = buildNestedAggregateToArrayQuery() |
no test coverage detected