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

Function hasOnlyLoadedIds

packages/db-collection-e2e/src/utils/helpers.ts:70–88  ·  view source on GitHub ↗
(
  collection: Collection<T>,
  ids: Array<string>,
)

Source from the content-addressed store, hash-verified

68 * Check if a collection has ONLY loaded specific IDs (no extras)
69 */
70export function hasOnlyLoadedIds<T extends { id: string }>(
71 collection: Collection<T>,
72 ids: Array<string>,
73): boolean {
74 const loadedIds = getLoadedIds(collection)
75 const idsSet = new Set(ids)
76
77 // Check that all loaded IDs are in expected IDs
78 if (!loadedIds.every((id) => idsSet.has(id))) {
79 return false
80 }
81
82 // Check that all expected IDs are loaded
83 if (!ids.every((id) => loadedIds.includes(id))) {
84 return false
85 }
86
87 return true
88}
89
90/**
91 * Wait for a collection to reach a specific size

Callers

nothing calls this directly

Calls 2

getLoadedIdsFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected