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
Copy file name to clipboardExpand all lines: docs/overview.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -163,10 +163,12 @@ You can also use:
163
163
164
164
#### Collection schemas
165
165
166
-
All collections optionally support a `schema`.
166
+
All collections optionally (though strongly recommended) support adding a `schema`.
167
167
168
168
If provided, this must be a [Standard Schema](https://standardschema.dev) compatible schema instance, such as a [Zod](https://zod.dev) or [Effect](https://effect.website/docs/schema/introduction/) schema.
169
169
170
+
The collection will use the schema to do client-side validation of optimistic mutations.
171
+
170
172
The collection will use the schema for its type so if you provide a schema, you can't also pass in an explicit
171
173
type (e.g. `createCollection<Todo>()`).
172
174
@@ -639,7 +641,7 @@ import { queryCollectionOptions } from "@tanstack/db-collections"
639
641
640
642
// Load data into collections using TanStack Query.
641
643
// It's common to define these in a `collections` module.
Copy file name to clipboardExpand all lines: examples/react/todo/CHANGELOG.md
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,7 +115,6 @@
115
115
When `collection.insert()`, `.update()`, or `.delete()` are called outside of an explicit transaction (i.e., not within `useOptimisticMutation`), the library now automatically creates a single-operation transaction and invokes the corresponding handler to persist the change.
116
116
117
117
Key changes:
118
-
119
118
-**`@tanstack/db`**: The `Collection` class now supports `onInsert`, `onUpdate`, and `onDelete` in its configuration. Direct calls to mutation methods will throw an error if the corresponding handler is not defined.
120
119
-**`@tanstack/db-collections`**:
121
120
-`queryCollectionOptions` now accepts the new handlers and will automatically `refetch` the collection's query after a handler successfully completes. This behavior can be disabled if the handler returns `{ refetch: false }`.
@@ -127,7 +126,6 @@
127
126
***
128
127
129
128
The documentation and the React Todo example application have been significantly refactored to adopt the new direct persistence handler pattern as the primary way to perform mutations.
130
-
131
129
- The `README.md` and `docs/overview.md` files have been updated to de-emphasize `useOptimisticMutation` for simple writes. They now showcase the much simpler API of calling `collection.insert()` directly and defining persistence logic in the collection's configuration.
132
130
- The React Todo example (`examples/react/todo/src/App.tsx`) has been completely overhauled. All instances of `useOptimisticMutation` have been removed and replaced with the new `onInsert`, `onUpdate`, and `onDelete` handlers, resulting in cleaner and more concise code.
0 commit comments