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

Function computeAggregateVirtualProps

packages/db/src/virtual-props.ts:238–255  ·  view source on GitHub ↗
(
  rows: Array<Partial<VirtualRowProps<string | number>>>,
  groupKey: TKey,
  collectionId: string,
)

Source from the content-addressed store, hash-verified

236 * @internal
237 */
238export function computeAggregateVirtualProps<TKey extends string | number>(
239 rows: Array<Partial<VirtualRowProps<string | number>>>,
240 groupKey: TKey,
241 collectionId: string,
242): VirtualRowProps<TKey> {
243 // $synced = true only if ALL rows are synced (false if ANY is optimistic)
244 const allSynced = rows.every((row) => row.$synced ?? true)
245
246 // $origin = 'local' if ANY row is local (consistent with "local influence" semantics)
247 const hasLocal = rows.some((row) => row.$origin === 'local')
248
249 return {
250 $synced: allSynced,
251 $origin: hasLocal ? 'local' : 'remote',
252 $key: groupKey,
253 $collectionId: collectionId,
254 }
255}
256
257/**
258 * List of virtual property names for iteration and checking.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected