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

Function wrappedOnInsert

packages/db/src/local-only.ts:195–208  ·  view source on GitHub ↗
(
    params: InsertMutationFnParams<T, TKey, LocalOnlyCollectionUtils>,
  )

Source from the content-addressed store, hash-verified

193 * Wraps the user's onInsert handler to also confirm the transaction immediately
194 */
195 const wrappedOnInsert = async (
196 params: InsertMutationFnParams<T, TKey, LocalOnlyCollectionUtils>,
197 ) => {
198 // Call user handler first if provided
199 let handlerResult
200 if (onInsert) {
201 handlerResult = (await onInsert(params)) ?? {}
202 }
203
204 // Then synchronously confirm the transaction by looping through mutations
205 syncResult.confirmOperationsSync(params.transaction.mutations)
206
207 return handlerResult
208 }
209
210 /**
211 * Wrapper for onUpdate handler that also confirms the transaction immediately

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected