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

Function splitUpdates

packages/db/src/query/live/utils.ts:307–321  ·  view source on GitHub ↗
(
  changes: Iterable<ChangeMessage<T, TKey>>,
)

Source from the content-addressed store, hash-verified

305
306/** Splits updates into a delete of the old value and an insert of the new value */
307export function* splitUpdates<
308 T extends object = Record<string, unknown>,
309 TKey extends string | number = string | number,
310>(
311 changes: Iterable<ChangeMessage<T, TKey>>,
312): Generator<ChangeMessage<T, TKey>> {
313 for (const change of changes) {
314 if (change.type === `update`) {
315 yield { type: `delete`, key: change.key, value: change.previousValue! }
316 yield { type: `insert`, key: change.key, value: change.value }
317 } else {
318 yield change
319 }
320 }
321}
322
323/**
324 * Filter changes to prevent duplicate inserts to a D2 pipeline.

Callers 2

startMethod · 0.85
sendChangesInRangeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected