MCPcopy Create free account
hub / github.com/TanStack/db / buildSingletonQuery

Function buildSingletonQuery

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

Source from the content-addressed store, hash-verified

6521 // For singleton behavior we look up each issue's parent project.
6522 // Each issue references exactly one project via projectId.
6523 function buildSingletonQuery() {
6524 return createLiveQueryCollection((q) =>
6525 q.from({ i: issues }).select(({ i }) => ({
6526 id: i.id,
6527 title: i.title,
6528 project: materialize(
6529 q
6530 .from({ p: projects })
6531 .where(({ p }) => eq(p.id, i.projectId))
6532 .select(({ p }) => ({
6533 id: p.id,
6534 name: p.name,
6535 }))
6536 .findOne(),
6537 ),
6538 })),
6539 )
6540 }
6541
6542 it(`findOne() materializes a single value, not an array`, async () => {
6543 const collection = buildSingletonQuery()

Callers 1

includes.test.tsFile · 0.85

Calls 7

materializeFunction · 0.85
selectMethod · 0.80
fromMethod · 0.80
findOneMethod · 0.80
whereMethod · 0.80
eqFunction · 0.70

Tested by

no test coverage detected