docs(query-db-collection): document scoped collection factories#1671
docs(query-db-collection): document scoped collection factories#1671KyleAMathews wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR documents business-scoped Query Collection factories, including scope-aware query keys and functions, stable memoization by ChangesBusiness-scoped collections
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
More templates
@tanstack/angular-db
@tanstack/browser-db-sqlite-persistence
@tanstack/capacitor-db-sqlite-persistence
@tanstack/cloudflare-durable-objects-db-sqlite-persistence
@tanstack/db
@tanstack/db-ivm
@tanstack/db-sqlite-persistence-core
@tanstack/electric-db-collection
@tanstack/electron-db-sqlite-persistence
@tanstack/expo-db-sqlite-persistence
@tanstack/node-db-sqlite-persistence
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/react-native-db-sqlite-persistence
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/tauri-db-sqlite-persistence
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: 0 B Total Size: 125 kB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 4.22 kB ℹ️ View Unchanged
|
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| '@tanstack/query-db-collection': patch | |||
There was a problem hiding this comment.
No need for a changeset on a docs only PR
Summary
Document how to create Query Collections for tenant, project, account, and route-level business scopes. The new guidance helps users preserve collection identity and lifecycle correctly without confusing business scope with relational subset loading.
Approach
QueryClientand a scope parameter.queryKeyandqueryFn.QueryClientand scope.collection.cleanup()for unbounded, long-lived scope caches.LoadSubsetOptionsrather than creating collections per subset.QueryClientand predicate push-down guidance instead of duplicating it.Key invariants
QueryClientand business scope.queryCollectionOptionsAPI.Non-goals
.bind(...)API or nested query configuration.Trade-offs
The example uses explicit
WeakMap<QueryClient, Map<scope, Collection>>memoization. This is more verbose than an implicit binding API, but keeps dependencies and lifecycle ownership visible while requiring no new runtime abstraction.Verification
pnpm prettier docs/collections/query-collection.md --check pnpm exec tsx scripts/verify-links.ts git diff origin/main --checkAll commands pass. The repository's
pnpm test:docswrapper cannot directly executescripts/verify-links.tsunder the current Node environment, so the same verifier was run through the installedtsxrunner.Files changed
docs/collections/query-collection.md— adds business-scoped factory, memoization, lifecycle, and relational-subset guidance..changeset/document-scoped-query-factories.md— records the documentation update for@tanstack/query-db-collection.Summary by CodeRabbit