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

Function mutationFn

packages/db/tests/collection.test.ts:328–352  ·  view source on GitHub ↗
({ transaction })

Source from the content-addressed store, hash-verified

326 })
327
328 const mutationFn: MutationFn = ({ transaction }) => {
329 // Redact time-based and random fields
330 const redactedTransaction = {
331 ...transaction,
332 mutations: {
333 ...transaction.mutations.map((mutation) => {
334 return {
335 ...mutation,
336 createdAt: `[REDACTED]`,
337 updatedAt: `[REDACTED]`,
338 mutationId: `[REDACTED]`,
339 }
340 }),
341 },
342 }
343
344 // Call the mock function with the redacted transaction
345 persistMock({ transaction: redactedTransaction })
346
347 // Call the mock function with the transaction
348 syncMock({ transaction })
349
350 emitter.emit(`sync`, transaction.mutations)
351 return Promise.resolve()
352 }
353
354 // Test insert with auto-generated key
355 const data = { id: 1, value: `bar` }

Callers 6

createOptimisticActionFunction · 0.50
electric.test.tsFile · 0.50
createOfflineActionMethod · 0.50
runMutationFnMethod · 0.50
wrappedMutationFunction · 0.50

Calls 4

expectFunction · 0.90
getStateEntriesFunction · 0.85
emitMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected