You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Clarify this is about not rewriting existing logic, not avoiding optimistic updates
- Add Electric's awaitTxId as a sync option
- Show collection-specific approaches (QueryCollection refetch vs Electric awaitTxId)
- Provide examples for both patterns
Copy file name to clipboardExpand all lines: docs/guides/mutations.md
+15-6Lines changed: 15 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,23 +38,32 @@ With an instant inner loop of optimistic state, superseded in time by the slower
38
38
> [!TIP]
39
39
> **You Can Skip TanStack DB Mutations Entirely**
40
40
>
41
-
> If you already have mutation logic in an existing system or simply prefer not to use optimistic updates, you can **completely bypass** TanStack DB's mutation system. For many collection types (especially `QueryCollection`), you can:
41
+
> If you already have mutation logic in an existing system and don't want to rewrite it, you can **completely bypass** TanStack DB's mutation system. For many collection types, you can:
42
42
>
43
-
> 1. Call your backend mutation API directly
44
-
> 2. Wait for sync systems to sync changes back, **OR** manually refetch the collection with `collection.utils.refetch()`
43
+
> 1. Call your backend mutation API directly (using your existing logic)
44
+
> 2. Wait for changes to sync back:
45
+
> -**QueryCollection**: Manually refetch with `collection.utils.refetch()`
46
+
> -**ElectricCollection**: Use `collection.utils.awaitTxId(txid)` to wait for sync
47
+
> -**Other sync systems**: Wait for your sync mechanism to update the collection
45
48
>
46
49
> ```tsx
47
50
>// Bypass TanStack DB mutations - use your existing mutation logic
> This approach is perfectly valid! The mutation system is optional and designed for scenarios where you want optimistic updates and automatic state management.
66
+
> This approach is perfectly valid! The mutation system is optional and designed for when you want the built-in optimistic updates and automatic state management patterns.
58
67
59
68
### Simplified Mutations vs Traditional Approaches
0 commit comments