Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

CHANGELOG.md

349 lines14.3 KB

@tanstack/query-db-collection

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 queryFn return 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 select and join clauses 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 writeBatch from 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

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 call markReady() 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 TanStackDBError class - 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 instanceof checks 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 instanceof checks
    • 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 TanStackDBError class 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.

  • 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() and markReady() (#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() with onFirstReady() for better semantics
    • Update status state machine to allow loading β†’ ready transition 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.

  • 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/db package
    • Create new @tanstack/electric-db-collection package for ElectricSQL integration
    • Create new @tanstack/query-db-collection package for TanStack Query integration
    • Delete @tanstack/db-collections package (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
  • Updated dependencies [8e23322]:

    • @tanstack/db@0.0.21