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

Function buildAggregateToArrayQuery

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

Source from the content-addressed store, hash-verified

3955
3956 describe(`single-group aggregate: count issues per project (as toArray)`, () => {
3957 function buildAggregateToArrayQuery() {
3958 return createLiveQueryCollection((q) =>
3959 q.from({ p: projects }).select(({ p }) => ({
3960 id: p.id,
3961 name: p.name,
3962 issueCount: toArray(
3963 q
3964 .from({ i: issues })
3965 .where(({ i }) => eq(i.projectId, p.id))
3966 .select(({ i }) => ({ total: count(i.id) })),
3967 ),
3968 })),
3969 )
3970 }
3971
3972 it(`each project gets its own aggregate result as an array`, async () => {
3973 const collection = buildAggregateToArrayQuery()

Callers 1

includes.test.tsFile · 0.85

Calls 7

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…