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

Function wrappedOnDelete

packages/db/src/local-storage.ts:507–530  ·  view source on GitHub ↗
(params: DeleteMutationFnParams<any>)

Source from the content-addressed store, hash-verified

505 }
506
507 const wrappedOnDelete = async (params: DeleteMutationFnParams<any>) => {
508 // Call the user handler BEFORE persisting changes (if provided)
509 let handlerResult: any = {}
510 if (config.onDelete) {
511 handlerResult = (await config.onDelete(params)) ?? {}
512 }
513
514 // Always persist to storage
515 // Use lastKnownData (in-memory cache) instead of reading from storage
516 // Remove items
517 params.transaction.mutations.forEach((mutation) => {
518 // Use the engine's pre-computed key for consistency
519 lastKnownData.delete(mutation.key)
520 })
521
522 // Save to storage
523 saveToStorage(lastKnownData)
524
525 // Confirm mutations through sync interface (moves from optimistic to synced state)
526 // without reloading from storage
527 sync.confirmOperationsSync(params.transaction.mutations)
528
529 return handlerResult
530 }
531
532 // Extract standard Collection config properties
533 const {

Callers

nothing calls this directly

Calls 3

saveToStorageFunction · 0.85
forEachMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected