@tanstack/query-db-collection#
0.2.22#
Patch Changes#
- Updated dependencies [
8cd0876]:- @tanstack/db@0.4.1
0.2.21#
Patch Changes#
Refactor the main Collection class into smaller classes to make it easier to maintain. (#560)
Updated dependencies [
2f87216,ac6250a,2f87216]:- @tanstack/db@0.4.0
0.2.20#
Patch Changes#
- Updated dependencies [
cacfca2]:- @tanstack/db@0.3.2
0.2.19#
Patch Changes#
- Updated dependencies [
5f51f35]:- @tanstack/db@0.3.1
0.2.18#
Patch Changes#
0.2.17#
Patch Changes#
Refactor of the types of collection config factories for better type inference. (#530)
Define BaseCollectionConfig interface and let all collections extend it. (#531)
Updated dependencies [
b03894d,3968087]:- @tanstack/db@0.2.5
0.2.16#
Patch Changes#
Add error tracking and retry methods to query collection utils. (#441)
Updated dependencies [
92febbf,b487430]:- @tanstack/db@0.2.4
0.2.15#
Patch Changes#
- Updated dependencies [
b162556]:- @tanstack/db@0.2.3
0.2.14#
Patch Changes#
- Updated dependencies [
33515c6]:- @tanstack/db@0.2.2
0.2.13#
Patch Changes#
- Updated dependencies [
620ebea]:- @tanstack/db@0.2.1
0.2.12#
Patch Changes#
0.2.11#
Patch Changes#
fix: race condition creating a collection from a query that has already loaded (#495)
Updated dependencies [
cc4c34a]:- @tanstack/db@0.1.12
0.2.10#
Patch Changes#
- Updated dependencies [
b869f68]:- @tanstack/db@0.1.11
0.2.9#
Patch Changes#
0.2.8#
Patch Changes#
- Updated dependencies [
d64b4a8]:- @tanstack/db@0.1.9
0.2.7#
Patch Changes#
0.2.6#
Patch Changes#
0.2.5#
Patch Changes#
- Updated dependencies [
ad33e9e]:- @tanstack/db@0.1.6
0.2.4#
Patch Changes#
Add type inference of the collection type from the query collection config
queryFnreturn type (#403)Updated dependencies [
9a5a20c]:- @tanstack/db@0.1.5
0.2.3#
Patch Changes#
0.2.2#
Patch Changes#
- Updated dependencies [
0cb7699]:- @tanstack/db@0.1.3
0.2.1#
Patch Changes#
Ensure that you can use optional properties in the
selectandjoinclauses of a query, and fix an issue where standard schemas were not properly carried through to live queries. (#377)Updated dependencies [
bb5d50e,97b595e]:- @tanstack/db@0.1.2
0.2.0#
Minor Changes#
- Improve writeBatch API to use callback pattern (#378)
- Changed
writeBatchfrom accepting an array of operations to accepting a callback function - Write operations called within the callback are automatically batched together
- This provides a more intuitive API similar to database transactions
- Added comprehensive documentation for Query Collections including direct writes feature
- Changed
0.1.3#
Patch Changes#
Add meta support to QueryCollectionConfig to allow passing additional context to queryFn. (#363)
Updated dependencies [
bc2f204,bda3f24]:- @tanstack/db@0.1.1
0.1.2#
Patch Changes#
- Move @tanstack/query-core from dependencies to peerDependencies to avoid version conflicts when users already have react-query or query-core installed. This is a non-breaking change as the package will continue to work with any 5.x version of query-core. (#351)
0.1.1#
Patch Changes#
- Add manual write methods to QueryCollectionUtils interface to enable direct state updates from external sources. Introduces writeInsert, writeUpdate, writeDelete, writeUpsert, and writeBatch methods that bypass the normal optimistic update flow for WebSocket/real-time scenarios. All methods include proper transaction handling, data validation, and automatic query cache synchronization. (#303)
0.1.0#
Minor Changes#
- 0.1 release - first beta π (#332)
Patch Changes#
0.0.15#
Patch Changes#
- Updated dependencies [
6e8d7f6]:- @tanstack/db@0.0.33
0.0.14#
Patch Changes#
Fix LiveQueryCollection hanging when source collections have no data (#309)
Fixed an issue where
LiveQueryCollection.preload()would hang indefinitely when source collections callmarkReady()without data changes (e.g., when queryFn returns empty array).The fix implements a proper event-based solution:
- Collections now emit empty change events when becoming ready with no data
- WHERE clause filtered subscriptions now correctly pass through empty ready signals
- Both regular and WHERE clause optimized LiveQueryCollections now work correctly with empty source collections
Updated dependencies [
e04bd12]:- @tanstack/db@0.0.32
0.0.13#
Patch Changes#
- Updated dependencies [
3e9a36d]:- @tanstack/db@0.0.31
0.0.12#
Patch Changes#
- Updated dependencies [
6bdde55]:- @tanstack/db@0.0.30
0.0.11#
Patch Changes#
feat: Replace string-based errors with named error classes for better error handling (#297)
This comprehensive update replaces all string-based error throws throughout the TanStack DB codebase with named error classes, providing better type safety and developer experience.
New Features#
- Root
TanStackDBErrorclass - all errors inherit from a common base for unified error handling - Named error classes organized by package and functional area
- Type-safe error handling using
instanceofchecks instead of string matching - Package-specific error definitions - each adapter has its own error classes
- Better IDE support with autocomplete for error types
Package Structure#
Core Package (
@tanstack/db)#Contains generic errors used across the ecosystem:
- Collection configuration, state, and operation errors
- Transaction lifecycle and mutation errors
- Query building, compilation, and execution errors
- Storage and serialization errors
Adapter Packages#
Each adapter now exports its own specific error classes:
@tanstack/electric-db-collection: Electric-specific errors@tanstack/trailbase-db-collection: TrailBase-specific errors@tanstack/query-db-collection: Query collection specific errors
Breaking Changes#
- Error handling code using string matching will need to be updated to use
instanceofchecks - Some error messages may have slight formatting changes
- Adapter-specific errors now need to be imported from their respective packages
Migration Guide#
Core DB Errors#
Before:
try { collection.insert(data) } catch (error) { if (error.message.includes("already exists")) { // Handle duplicate key error } }After:
import { DuplicateKeyError } from "@tanstack/db" try { collection.insert(data) } catch (error) { if (error instanceof DuplicateKeyError) { // Type-safe error handling } }Adapter-Specific Errors#
Before:
// Electric collection errors were imported from @tanstack/db import { ElectricInsertHandlerMustReturnTxIdError } from "@tanstack/db"After:
// Now import from the specific adapter package import { ElectricInsertHandlerMustReturnTxIdError } from "@tanstack/electric-db-collection"Unified Error Handling#
New:
import { TanStackDBError } from "@tanstack/db" try { // Any TanStack DB operation } catch (error) { if (error instanceof TanStackDBError) { // Handle all TanStack DB errors uniformly console.log("TanStack DB error:", error.message) } }Benefits#
- Type Safety: All errors now have specific types that can be caught with
instanceof - Unified Error Handling: Root
TanStackDBErrorclass allows catching all library errors with a single check - Better Package Separation: Each adapter manages its own error types
- Developer Experience: Better IDE support with autocomplete for error types
- Maintainability: Error definitions are co-located with their usage
- Consistency: Uniform error handling patterns across the entire codebase
All error classes maintain the same error messages and behavior while providing better structure and package separation.
- Root
Updated dependencies [
ced0657,dcfef51,360b0df,608be0c,5260ee3]:- @tanstack/db@0.0.29
0.0.10#
Patch Changes#
0.0.9#
Patch Changes#
- Updated dependencies [
bec8620]:- @tanstack/db@0.0.27
0.0.8#
Patch Changes#
Add initial release of TrailBase collection for TanStack DB. TrailBase is a blazingly fast, open-source alternative to Firebase built on Rust, SQLite, and V8. It provides type-safe REST and realtime APIs with sub-millisecond latencies, integrated authentication, and flexible access control - all in a single executable. This collection type enables seamless integration with TrailBase backends for high-performance real-time applications. (#228)
Updated dependencies [
09c6995]:- @tanstack/db@0.0.26
0.0.7#
Patch Changes#
Add explicit collection readiness detection with
isReady()andmarkReady()(#270)- Add
isReady()method to check if a collection is ready for use - Add
onFirstReady()method to register callbacks for when collection becomes ready - Add
markReady()to SyncConfig interface for sync implementations to explicitly signal readiness - Replace
onFirstCommit()withonFirstReady()for better semantics - Update status state machine to allow
loadingβreadytransition for cases with no data to commit - Update all sync implementations (Electric, Query, Local-only, Local-storage) to use
markReady() - Improve error handling by allowing collections to be marked ready even when sync errors occur
This provides a more intuitive and ergonomic API for determining collection readiness, replacing the previous approach of using commits as a readiness signal.
- Add
Updated dependencies [
1758eda,20f810e]:- @tanstack/db@0.0.25
0.0.6#
Patch Changes#
0.0.5#
Patch Changes#
- Updated dependencies [
056609e]:- @tanstack/db@0.0.23
0.0.4#
Patch Changes#
- Updated dependencies [
aeee9a1]:- @tanstack/db@0.0.22
0.0.3#
Patch Changes#
Move Collections to their own packages (#252)
- Move local-only and local-storage collections to main
@tanstack/dbpackage - Create new
@tanstack/electric-db-collectionpackage for ElectricSQL integration - Create new
@tanstack/query-db-collectionpackage for TanStack Query integration - Delete
@tanstack/db-collectionspackage (removed from repo) - Update example app and documentation to use new package structure
Why?
- Better separation of concerns
- Independent versioning for each collection type
- Cleaner dependencies (electric collections don't need query deps, etc.)
- Easier to add more collection types moving forward
- Move local-only and local-storage collections to main
Updated dependencies [
8e23322]:- @tanstack/db@0.0.21