(params: DeleteMutationFnParams<any>)
| 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 { |
nothing calls this directly
no test coverage detected