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

Function buildToArrayToCollectionQuery

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

Source from the content-addressed store, hash-verified

1754
1755 describe(`nested includes: toArray → Collection`, () => {
1756 function buildToArrayToCollectionQuery() {
1757 return createLiveQueryCollection((q) =>
1758 q.from({ p: projects }).select(({ p }) => ({
1759 id: p.id,
1760 name: p.name,
1761 issues: toArray(
1762 q
1763 .from({ i: issues })
1764 .where(({ i }) => eq(i.projectId, p.id))
1765 .select(({ i }) => ({
1766 id: i.id,
1767 title: i.title,
1768 comments: q
1769 .from({ c: comments })
1770 .where(({ c }) => eq(c.issueId, i.id))
1771 .select(({ c }) => ({
1772 id: c.id,
1773 body: c.body,
1774 })),
1775 })),
1776 ),
1777 })),
1778 )
1779 }
1780
1781 it(`initial load: issues are arrays, comments are Collections`, async () => {
1782 const collection = buildToArrayToCollectionQuery()

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…