forked from TanStack/db
-
Notifications
You must be signed in to change notification settings - Fork 0
Update From Upstream #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Add WIP version of mutations guide * add before/after example * docs: clean up mutation handler examples - Pull mutation off mutations array for cleaner code - Add comment explaining collection handlers only receive one mutation at a time - Apply pattern consistently across all handler examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: remove pioneer analogy * docs: fix mutation handler patterns - Remove incorrect comment about single mutations - Update handlers to use Promise.all for multiple mutations - Fix collection.refetch() -> collection.utils.refetch() - Update Electric collection pattern to return txids - Add note about automatic refetch in collection handlers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: fix temporary ID generator bug Parenthesize the offset to ensure negative IDs: -(Math.floor(...) + 1) Previously could produce positive 1 when Math.random() returns 0 * docs: clarify Immer-like pattern usage Use 'Immer-like pattern' instead of 'uses Immer under the hood' * docs: fix operation handler signatures - Correct handler params to { transaction, collection } - Remove incorrect metadata parameter from signature - Add metadata to mutation object properties list - Fix return type to Promise<any> | any * docs: clarify handler sync requirements Replace QueryCollection-specific note with general requirement that handlers must wait for server changes to sync back before resolving * docs: remove unnecessary refetch call in generic mutation function Collection handlers automatically handle refetch, only custom actions need it * docs: clarify commit timing with example * docs: fix TransactionConfig options - Make mutationFn required (not optional) - Add missing id and metadata options - Mark autoCommit as optional * docs: clarify when to manually rollback transactions Note that rollback is automatic on error, manual rollback only needed for user actions like canceling a form * docs: streamline mutation merging section - Replace opening paragraph with bullet points - Remove worked examples, keep truth table only - Remove redundant benefits list * Add an example. --------- Co-authored-by: Claude <[email protected]>
* Add WIP version of mutations guide * add before/after example * docs: clean up mutation handler examples - Pull mutation off mutations array for cleaner code - Add comment explaining collection handlers only receive one mutation at a time - Apply pattern consistently across all handler examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: remove pioneer analogy * docs: fix mutation handler patterns - Remove incorrect comment about single mutations - Update handlers to use Promise.all for multiple mutations - Fix collection.refetch() -> collection.utils.refetch() - Update Electric collection pattern to return txids - Add note about automatic refetch in collection handlers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: fix temporary ID generator bug Parenthesize the offset to ensure negative IDs: -(Math.floor(...) + 1) Previously could produce positive 1 when Math.random() returns 0 * docs: clarify Immer-like pattern usage Use 'Immer-like pattern' instead of 'uses Immer under the hood' * docs: fix operation handler signatures - Correct handler params to { transaction, collection } - Remove incorrect metadata parameter from signature - Add metadata to mutation object properties list - Fix return type to Promise<any> | any * docs: clarify handler sync requirements Replace QueryCollection-specific note with general requirement that handlers must wait for server changes to sync back before resolving * docs: remove unnecessary refetch call in generic mutation function Collection handlers automatically handle refetch, only custom actions need it * docs: clarify commit timing with example * docs: fix TransactionConfig options - Make mutationFn required (not optional) - Add missing id and metadata options - Mark autoCommit as optional * docs: clarify when to manually rollback transactions Note that rollback is automatic on error, manual rollback only needed for user actions like canceling a form * docs: streamline mutation merging section - Replace opening paragraph with bullet points - Remove worked examples, keep truth table only - Remove redundant benefits list * Add an example. * add missing link to mutations doc in config --------- Co-authored-by: Claude <[email protected]>
* add repo of asc/desc index bug * Fix bug with asc/desc indexes by tracking compare options in each index * Fix and add unit tests for ordering options * Modify BTreeIndex.take to properly handle null values * Fix unit test * Changeset --------- Co-authored-by: Kevin De Porre <[email protected]>
) * fix: keep live queries in sync during long optimistic commits * docs: note live-query optimistic fix in changeset * chore: document optimistic commit behaviour * test: consolidate live-query optimistic scenarios * chore: clarify forced emit batching comment * test: handle live query optimistic helpers safely
* Reverse index if direction doesn't match. * Changeset
* add findOne() to query builder * move utility type to db/types * fix utility type * add single support to aditional useLiveQuery overloads * Add support for specifying `.findOne()` outside of a query builder * WIP addressing of the review * fix for review * remove unused offset * restore text comments * restore text comments * disable limit=1 for future enforcing --------- Co-authored-by: Sam Willis <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…tack#650) * add failing test * fix * changeset
* Update issue templates * Update bug_report.md * format
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Add onLoadMore callback and call it from the requestSnapshot methods * Export IR * Fixes to subscription * Remove debug logging in ts DB * Fix cleanup function returned from utility test * Linting * Fix state reference * Update lockfile * Changeset * Break import cycle * Update lockfile * Fix vite config
* docs: add debugging section for awaitTxId stalling issues Add comprehensive debugging guide to help developers diagnose and fix the common issue where awaitTxId stalls or times out. This happens when pg_current_xact_id() is queried outside the mutation transaction, causing txid mismatches. The guide includes: - Explanation of the root cause (txid mismatch) - How to enable debug logging with localStorage.debug = '*' - Example logs showing both mismatched and matched txids - Correct pattern for querying txid inside sql.begin() - References to working examples in the codebase 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Apply suggestion from @samwillis Co-authored-by: Sam Willis <[email protected]> * Update electric-collection.md --------- Co-authored-by: Claude <[email protected]> Co-authored-by: Sam Willis <[email protected]>
* add collection id to important logs Signed-off-by: Marc MacLeod <[email protected]> * add changeset Signed-off-by: Marc MacLeod <[email protected]> * update test snapshot Signed-off-by: Marc MacLeod <[email protected]> --------- Signed-off-by: Marc MacLeod <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Show how to use schema validation libraries (Zod, Valibot, Yup, etc.) with createOptimisticAction for type-safe, runtime-validated actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
…nStack#402) (TanStack#499) * feat: Add flexible matching strategies for electric-db-collection (TanStack#402) - Add three matching strategies for client-server synchronization: 1. Txid strategy (existing, backward compatible) 2. Custom match function strategy (new) 3. Void/timeout strategy (new, 3-second default) - New types: MatchFunction<T>, MatchingStrategy<T> - Enhanced ElectricCollectionConfig to support all strategies - New utility: awaitMatch(matchFn, timeout?) - Export isChangeMessage and isControlMessage helpers - Remove deprecated error classes (beta compatibility not required) - Comprehensive tests for all strategies including timeout behavior - Updated documentation with detailed examples and migration guide Benefits: - Backward compatibility maintained - Architecture flexibility for different backend capabilities - Progressive enhancement path - No forced backend API changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * fix: Address code review feedback - commit semantics, memory leaks, and API consistency Critical fixes based on thorough code review: **🔧 Commit Semantics Fix:** - awaitMatch now waits for up-to-date after finding match (like awaitTxId) - Ensures consistent behavior between txid and custom match strategies - Prevents race conditions where mutations marked "persisted" before actual commit **🧠 Memory Leak Fixes:** - Properly cleanup pendingMatches on timeout and abort - Add abort listener to cleanup all pending matches on stream abort - Use cross-platform ReturnType<typeof setTimeout> instead of NodeJS.Timeout **🎯 API Consistency:** - Unified MatchingStrategy type used across all handler return types - Support configurable timeout for void strategy: { timeout: 1500 } - Remove unused discriminator type field for cleaner duck-typed unions **🧪 Enhanced Test Coverage:** - Test memory cleanup after timeout (no lingering handlers) - Test commit semantics (awaitMatch waits for up-to-date) - Test configurable void timeout functionality - All edge cases now properly covered **📦 Version Bump:** - Changeset updated to minor (removed exported error classes) All feedback addressed while maintaining backward compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * format * fix: Address critical lifecycle and safety issues in matching strategies Based on engineering feedback, this commit addresses several critical edge cases: **Memory Safety & Error Handling:** - Fix timeout cleanup memory leak in awaitMatch - pending matchers now properly removed on timeout - Add try/catch around matchFn calls to prevent user code from crashing stream loop - Add proper abort semantics with StreamAbortedError for pending matches - Add TimeoutWaitingForMatchError following codebase error class conventions **Race Condition Fix:** - Implement up-to-date bounded message buffer to handle race where messages arrive before matcher registration - Buffer is safely bounded to current transaction batch, eliminating stale data matching risks - Messages cleared on each up-to-date to maintain transaction boundaries **Test Reliability:** - Replace timing-based assertions with fake timers using vi.runOnlyPendingTimersAsync() - Eliminates CI flakiness while testing the same void strategy functionality **Cross-platform Compatibility:** - Confirmed ReturnType<typeof setTimeout> usage for browser compatibility - API shape consistency already matches runtime behavior The core matching strategy design (txid/custom/void) remains unchanged - these are lifecycle polish fixes for production readiness. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * Fix TypeScript build error in ElectricCollectionConfig The interface was extending BaseCollectionConfig with a strict handler return type of { txid: ... }, but our new matching strategies support broader return types including matchFn and void strategies. Removed the extends constraint and manually included needed properties to allow handlers to return any MatchingStrategy type. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Fix electric collection test unhandled rejections * Simplify matching strategies API based on review feedback - Simplify MatchingStrategy type to only support { txid } or void - Remove awaitVoid function and timeout parameter support - Make ElectricCollectionConfig extend BaseCollectionConfig - Fix duplicate match.matched setting in awaitMatch - Extract cleanup logic to removePendingMatches helper - Simplify map call to use result.txid.map(awaitTxId) - Update all JSDoc comments to reflect new API - Update documentation to show three approaches: 1. Using { txid } (recommended) 2. Using collection.utils.awaitMatch() for custom matching 3. Using simple setTimeout for prototyping - Fix all tests to use new API with collection.utils.awaitMatch() Addresses PR review comments from kevin-dp and samwillis 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Set awaitTxId default timeout to 5 seconds Reduce default timeout from 30s to 5s for faster feedback when txids don't match or sync issues occur. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Update changeset to reflect current API changes Document awaitMatch utility and timeout reduction from 30s to 5s. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * format * cleanup changeset * better wording * Delete packages/db/src/collection.ts.backup * Delete packages/db/tests/collection.test.ts.backup * wording * Remove void/no-wait pattern from handler examples Remove documentation of the void return pattern from onInsert, onUpdate, and onDelete handlers. Handlers should always wait for synchronization to prevent UI glitches. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Delete # Introducing TanStack DB 0.md * Extract match resolution logic into helper function Create resolveMatchedPendingMatches() helper to clean up the code that resolves and removes matched pending matches on up-to-date messages. Addresses review feedback from kevin-dp about extracting cleanup logic. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
…ons (TanStack#638) * Add acceptMutations utility for local collections in manual transactions Fixes TanStack#446 Local-only and local-storage collections now expose `utils.acceptMutations(transaction, collection)` that must be called in manual transaction `mutationFn` to persist mutations. This provides explicit control over when local mutations are persisted, following the pattern established by query-db-collection. Changes: - Add acceptMutations to LocalOnlyCollectionUtils interface - Add acceptMutations to LocalStorageCollectionUtils interface - Include JSON serialization validation in local-storage acceptMutations - Update documentation with manual transaction usage examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * format * Update changeset for acceptMutations feature 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Fix type errors in acceptMutations utility functions Replace `unknown` with `Record<string, unknown>` in PendingMutation type parameters and related generics to satisfy the `T extends object` constraint. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Fix type annotation in local-only test Add LocalOnlyCollectionUtils type parameter to createCollection call to satisfy type constraints after merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Remove redundant collection parameter from acceptMutations and add documentation Simplified acceptMutations() to no longer require passing the collection instance as a parameter, since it's called as a method on the collection's utils and can internally track which collection it belongs to via closure. Code changes: - Update type signatures to remove collection parameter - Capture collection reference in sync initialization - Fix type compatibility issues with mutation handlers - Update all JSDoc examples Documentation changes: - Add acceptMutations documentation to overview.md - Add "Using with Local Collections" section to mutations.md - Include examples showing basic usage and mixing local/server collections 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Apply reviewer feedback: fix key derivation and document transaction ordering Critical fixes: - Use mutation.key instead of recomputing with getKey() in acceptMutations This fixes delete operations and handles key changes on updates correctly Documentation improvements: - Update all examples to call acceptMutations after API success (recommended) - Add comprehensive "Transaction Ordering" section explaining trade-offs - Document when to persist before vs after API calls - Clarify that calling acceptMutations after API provides transactional consistency The mutation.key is pre-computed by the engine and handles edge cases like: - Delete operations where modified may be undefined - Update operations where the key field changes - Avoiding unnecessary recomputation Thanks to external reviewer for catching the delete key bug and suggesting the transaction ordering documentation improvements. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * remove file * Add comprehensive tests for acceptMutations in local collections Add test coverage for the acceptMutations utility in both local-only and local-storage collections to ensure proper behavior with manual transactions. Tests cover: - Basic mutation acceptance and persistence - Collection-specific filtering - Insert, update, and delete operations - Transaction ordering (before/after API calls) - Rollback behavior on transaction failure - Storage persistence verification (local-storage) Also fix local-storage implementation to properly confirm mutations by: - Adding confirmOperationsSync function to move mutations from optimistic to synced state - Using collection ID for filtering when collection reference isn't yet available - Ensuring mutations are properly persisted to both storage and collection state 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fixes * Remove any types from local-only collection options Replace all `any` types with proper generics for full type safety: - Made implementation function generic over T, TSchema, and TKey - Updated wrapped mutation handlers to use proper generic types - Typed collection variable as Collection<T, TKey, LocalOnlyCollectionUtils> - Updated confirmOperationsSync to use Array<PendingMutation<T>> - Created LocalOnlyCollectionOptionsResult helper type to properly type mutation handlers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Fix type error in acceptMutations Add type assertion when calling confirmOperationsSync to handle the widened mutation type from Record<string, unknown> to T. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* add failing tests * wip fixes * more tests * changeset
* eagerly run live queries while collections are loading * remove the initialCommit state * allow auto-indexing during sync * add tests to validate the before ready bahaviour * changeset * add test of optimistic behaviour * remove remaining ref to initialCommit status * add react tests * add eager hook tests to the other frameworks
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ubquery (TanStack#654) * new failing test * dont push down where clauses that match a select projection in a subquery * tweaks
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…composition of inner+anti joins (TanStack#571) * first refactor * second pass * futher optimisations * changeset * format * Address review * additional comments
…inside a live query (TanStack#625) * wip * convert to a subscription per alias * change to subscription per source alias, rather than per colleciton * address gpt5 review * wip * rename stuff * remove fallback to collecitonId * better mapping of subquery aliases * rename stuff and tidy * changeset * better comments * remove unnecessary second pass of the compiler * remove deplicate code * comments on aliasRemapping and additional tests to confirm * more comments * fix commit
…due to a transaction that touches multiple source collections (TanStack#628) add schedular address feedback with large refactor tweaks
* ci: add PR release comments * Fix PR/issue templates
* Refactor types and cleanup in rxdb.ts Replaces generic 'any' types with more specific types such as 'Subscription' and 'Record<string, unknown>' for improved type safety. Removes unnecessary type assertions and updates function signatures and variable declarations accordingly. * Filter out deleted documents in sync queries Added '_deleted': false to query selectors to ensure only non-deleted documents are included during synchronization. This improves data consistency by excluding soft-deleted records from sync operations. * Refactor stripRxdbFields function signature Updated the stripRxdbFields function to use a stricter type for the input parameter and removed unnecessary handling for arrays and nullish values. * Add rxjs as peer dependency Added 'rxjs' with version >=7.8.2 to peerDependencies in package.json to ensure compatibility and proper dependency management. * changeset --------- Co-authored-by: Sam Willis <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Mutable window for topK operator + unit tests * Make window mutable in orderBy operator + unit tests * Use compareFractionalIndex helper function in topKWithFractionalIndex tests * Helper function used by topK to compute diffs between windows * Thread move function from ts/db through to the underlying db-ivm operators * Fixes to ensure that lazy collections load missing data when an ordered query is moved * Unit tests for moving a live query * Pass necessary setMoveFn to the compileQuery calls in unit tests * changeset * linting * fold MoveUtils into LiveQueryCollectionUtils * fix utils types * rename move fn * fix local only utils types * tweaks --------- Co-authored-by: Sam Willis <[email protected]>
* wip * refactor so both CollectionEventsManager and CollectionSubscription subclass the same event emiiter implimetation * changeset * rename loadMore to loadSubset * feed the subscription object through to the loadSubset call, and add an unsunbscribed event to it * feed subscription through to the loadSubset callback, add unsubscribe event to the subscription, fix types * add sync mode to base colleciton * loadSubset fn return promise or true * add comment on setting is loading * address review * remove public trackLoadPromise * setWindow returns a promise when it triggers loading subset * feat: implement useLiveInfiniteQuery hook for React (TanStack#666) * feat: implement useLiveInfiniteQuery hook for React * use the new utils.setWindow to page through the results improve types add test that checks that we detect new pages on more rows syncing changeset tweaks * isFetchingNextPage set by promise from setWindow --------- Co-authored-by: Sam Willis <[email protected]> --------- Co-authored-by: Kyle Mathews <[email protected]>
…dSubset features (TanStack#679) Fix changeset for PR TanStack#669 to accurately describe features Updated changeset to correctly describe: - isLoadingSubset property (not isLoadingMore) - loadingSubset:change events - syncMode configuration options - Comprehensive loading state tracking - Enhanced setWindow utility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…anStack#695) Add comprehensive documentation for three undocumented live query features: 1. Conditional queries via undefined/null return - Document how to disable queries by returning undefined/null from useLiveQuery - Explain the disabled state (status: 'disabled', isEnabled: false) - Show practical "wait until inputs exist" pattern 2. Alternative useLiveQuery callback return types - Document returning pre-created Collections - Document returning LiveQueryCollectionConfig objects - Show use cases for each approach 3. isUndefined and isNull query functions - Add to Expression Functions Reference - Explain semantic difference between undefined vs null - Show examples with joins and optional properties These features were added in PR TanStack#535 and DB 0.2.0 but were not previously documented in the Live Queries guide. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…ronments (TanStack#696) * feat: Add in-memory fallback for localStorage collections in SSR environments Prevents LocalStorageCollectionError when localStorage collections are imported on the server by automatically falling back to an in-memory store. This addresses issue TanStack#691 where importing client code with localStorage collections in server environments would throw errors during module initialization. Changes: - Add createInMemoryStorage() to provide in-memory StorageApi fallback - Add createNoOpStorageEventApi() for server environments without window - Update localStorageCollectionOptions to use fallbacks instead of throwing errors - Remove unused NoStorageAvailableError and NoStorageEventApiError imports - Update tests to verify fallback behavior instead of expecting errors - Update JSDoc to document fallback behavior This allows isomorphic JavaScript applications to safely import localStorage collection modules without errors, though data will not persist across reloads or sync across tabs when using the in-memory fallback. Fixes TanStack#691 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * chore: Remove unused NoStorageAvailableError and NoStorageEventApiError classes These error classes are no longer used after implementing the in-memory fallback for localStorage collections in SSR environments. Removes dead code to keep the codebase clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * chore: Add changeset for in-memory fallback feature 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * fix: Update changeset to patch version (pre-1.0 project) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * chore: Update changeset to not reference deleted error class 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
…anStack#703) * docs: improve incremental updates example in query-collection docs Replace confusing manual optimistic update pattern with familiar onInsert/onUpdate handler pattern. Show how to: - Use persistence handlers (onInsert, onUpdate) like regular collections - Return { refetch: false } to avoid unnecessary refetches - Sync server-computed fields using direct writes within handlers This makes the example more approachable and consistent with the rest of the documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * docs: remove unnecessary writeDelete from query-collection example Optimistic state is automatically removed when the mutation handler returns, so there's no need to manually delete optimistic items. The handler just needs to write the server response to the synced data store, and when it completes, the optimistic state is automatically replaced. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
Chriztiaan
approved these changes
Oct 22, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This updates the main branch from upstream. This only includes changes from upstream. We don't have any custom code in this fork's
mainbranch. The diff is only for upstream code.