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

Function buildCollectionToArrayQuery

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

Source from the content-addressed store, hash-verified

1528
1529 describe(`nested includes: Collection → toArray`, () => {
1530 function buildCollectionToArrayQuery() {
1531 return createLiveQueryCollection((q) =>
1532 q.from({ p: projects }).select(({ p }) => ({
1533 id: p.id,
1534 name: p.name,
1535 issues: q
1536 .from({ i: issues })
1537 .where(({ i }) => eq(i.projectId, p.id))
1538 .select(({ i }) => ({
1539 id: i.id,
1540 title: i.title,
1541 comments: toArray(
1542 q
1543 .from({ c: comments })
1544 .where(({ c }) => eq(c.issueId, i.id))
1545 .select(({ c }) => ({
1546 id: c.id,
1547 body: c.body,
1548 })),
1549 ),
1550 })),
1551 })),
1552 )
1553 }
1554
1555 it(`initial load: issues are Collections, comments are arrays`, async () => {
1556 const collection = buildCollectionToArrayQuery()

Callers 1

includes.test.tsFile · 0.85

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…