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

Method keys

packages/db/src/collection/state.ts:389–405  ·  view source on GitHub ↗

* Get all keys (virtual derived state)

()

Source from the content-addressed store, hash-verified

387 * Get all keys (virtual derived state)
388 */
389 public *keys(): IterableIterator<TKey> {
390 const { syncedData, optimisticDeletes, optimisticUpserts } = this
391 // Yield keys from synced data, skipping any that are deleted.
392 for (const key of syncedData.keys()) {
393 if (!optimisticDeletes.has(key)) {
394 yield key
395 }
396 }
397 // Yield keys from upserts that were not already in synced data.
398 for (const key of optimisticUpserts.keys()) {
399 if (!syncedData.has(key) && !optimisticDeletes.has(key)) {
400 // The optimisticDeletes check is technically redundant if inserts/updates always remove from deletes,
401 // but it's safer to keep it.
402 yield key
403 }
404 }
405 }
406
407 /**
408 * Get all values (virtual derived state)

Callers 5

valuesMethod · 0.95
entriesMethod · 0.95
calculateSizeMethod · 0.45

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected