MCPcopy Index your code
hub / github.com/TanStack/db / buildNestedAggregateQuery

Function buildNestedAggregateQuery

packages/db/tests/query/includes.test.ts:3991–4009  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3989
3990 describe(`nested aggregate: count comments per issue (as Collection)`, () => {
3991 function buildNestedAggregateQuery() {
3992 return createLiveQueryCollection((q) =>
3993 q.from({ p: projects }).select(({ p }) => ({
3994 id: p.id,
3995 name: p.name,
3996 issues: q
3997 .from({ i: issues })
3998 .where(({ i }) => eq(i.projectId, p.id))
3999 .select(({ i }) => ({
4000 id: i.id,
4001 title: i.title,
4002 commentCount: q
4003 .from({ c: comments })
4004 .where(({ c }) => eq(c.issueId, i.id))
4005 .select(({ c }) => ({ total: count(c.id) })),
4006 })),
4007 })),
4008 )
4009 }
4010
4011 it(`each issue gets its own comment count`, async () => {
4012 const collection = buildNestedAggregateQuery()

Callers 1

includes.test.tsFile · 0.85

Calls 6

selectMethod · 0.80
fromMethod · 0.80
whereMethod · 0.80
eqFunction · 0.70
countFunction · 0.50

Tested by

no test coverage detected