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

Function assertLoadedAtLeast

packages/db-collection-e2e/src/utils/assertions.ts:39–54  ·  view source on GitHub ↗
(
  collection: Collection<T>,
  expectedIds: Array<string>,
  message?: string,
)

Source from the content-addressed store, hash-verified

37 * Assert that a collection has loaded at least the expected items (may have more)
38 */
39export function assertLoadedAtLeast<T extends { id: string }>(
40 collection: Collection<T>,
41 expectedIds: Array<string>,
42 message?: string,
43) {
44 const loadedIds = getLoadedIds(collection)
45 const loadedSet = new Set(loadedIds)
46
47 const missingIds = expectedIds.filter((id) => !loadedSet.has(id))
48 if (missingIds.length > 0) {
49 throw new Error(
50 message ??
51 `Collection is missing items: ${missingIds.join(`, `)} (loaded: ${loadedIds.join(`, `)})`,
52 )
53 }
54}
55
56/**
57 * Assert that a collection has NOT loaded any of the specified items

Callers

nothing calls this directly

Calls 4

getLoadedIdsFunction · 0.90
filterMethod · 0.80
hasMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…