Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions .changeset/cursor-pagination-loadsubset.md

This file was deleted.

23 changes: 0 additions & 23 deletions .changeset/deterministic-collection-ordering.md

This file was deleted.

18 changes: 0 additions & 18 deletions .changeset/multi-column-orderby-loadsubset.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/stable-order-tiebreaker.md

This file was deleted.

6 changes: 3 additions & 3 deletions examples/react/offline-transactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"start": "node .output/server/index.mjs"
},
"dependencies": {
"@tanstack/offline-transactions": "^1.0.1",
"@tanstack/query-db-collection": "^1.0.6",
"@tanstack/react-db": "^0.1.55",
"@tanstack/offline-transactions": "^1.0.2",
"@tanstack/query-db-collection": "^1.0.7",
"@tanstack/react-db": "^0.1.56",
"@tanstack/react-query": "^5.90.12",
"@tanstack/react-router": "^1.140.0",
"@tanstack/react-router-devtools": "^1.140.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/projects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"dependencies": {
"@tailwindcss/vite": "^4.1.17",
"@tanstack/query-core": "^5.90.12",
"@tanstack/query-db-collection": "^1.0.6",
"@tanstack/react-db": "^0.1.55",
"@tanstack/query-db-collection": "^1.0.7",
"@tanstack/react-db": "^0.1.56",
"@tanstack/react-router": "^1.140.0",
"@tanstack/react-router-devtools": "^1.140.0",
"@tanstack/react-router-with-query": "^1.130.17",
Expand Down
7 changes: 7 additions & 0 deletions packages/angular-db/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/angular-db

## 0.1.38

### Patch Changes

- Updated dependencies [[`b3b1940`](https://github.com/TanStack/db/commit/b3b194000d8efcc2c6cc45a663029dadc26f13f0), [`09da081`](https://github.com/TanStack/db/commit/09da081b420fc915d7f0dc566c6cdbbc78582435), [`86ad40c`](https://github.com/TanStack/db/commit/86ad40c6bc37b2f5d4ad24d06f72168ca4b96161)]:
- @tanstack/db@0.5.12

## 0.1.37

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-db/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/angular-db",
"version": "0.1.37",
"version": "0.1.38",
"description": "Angular integration for @tanstack/db",
"author": "Ethan McDaniel",
"license": "MIT",
Expand Down
10 changes: 10 additions & 0 deletions packages/db-ivm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @tanstack/db-ivm

## 0.1.14

### Patch Changes

- Use row keys for stable tie-breaking in ORDER BY operations instead of hash-based object IDs. ([#957](https://github.com/TanStack/db/pull/957))

Previously, when multiple rows had equal ORDER BY values, tie-breaking used `globalObjectIdGenerator.getId(key)` which could produce hash collisions and wasn't stable across page reloads for object references. Now, the row key (which is always `string | number` and unique per row) is used directly for tie-breaking, ensuring deterministic and stable ordering.

This also simplifies the internal `TaggedValue` type from a 3-tuple `[K, V, Tag]` to a 2-tuple `[K, V]`, removing unnecessary complexity.

## 0.1.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/db-ivm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/db-ivm",
"version": "0.1.13",
"version": "0.1.14",
"description": "Incremental View Maintenance for TanStack DB based on Differential Dataflow",
"author": "Sam Willis",
"license": "MIT",
Expand Down
67 changes: 67 additions & 0 deletions packages/db/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,72 @@
# @tanstack/db

## 0.5.12

### Patch Changes

- Enhanced LoadSubsetOptions with separate cursor expressions and offset for flexible pagination. ([#960](https://github.com/TanStack/db/pull/960))

**⚠️ Breaking Change for Custom Sync Layers / Query Collections:**

`LoadSubsetOptions.where` no longer includes cursor expressions for pagination. If you have a custom sync layer or query collection that implements `loadSubset`, you must now handle pagination separately:
- **Cursor-based pagination:** Use the new `cursor` property (`cursor.whereFrom` and `cursor.whereCurrent`) and combine them with `where` yourself
- **Offset-based pagination:** Use the new `offset` property

Previously, cursor expressions were baked into the `where` clause. Now they are passed separately so sync layers can choose their preferred pagination strategy.

**Changes:**
- Added `CursorExpressions` type with `whereFrom`, `whereCurrent`, and optional `lastKey` properties
- Added `cursor` to `LoadSubsetOptions` for cursor-based pagination (separate from `where`)
- Added `offset` to `LoadSubsetOptions` for offset-based pagination support
- Electric sync layer now makes two parallel `requestSnapshot` calls when cursor is present:
- One for `whereCurrent` (all ties at boundary, no limit)
- One for `whereFrom` (rows after cursor, with limit)
- Query collection serialization now includes `offset` for query key generation
- Added `truncate` event to collections, emitted when synced data is truncated (e.g., after `must-refetch`)
- Fixed `setWindow` pagination: cursor expressions are now correctly built when paging through results
- Fixed offset tracking: `loadNextItems` now passes the correct window offset to prevent incorrect deduplication
- `CollectionSubscriber` now listens for `truncate` events to reset cursor tracking state

**Benefits:**
- Sync layers can choose between cursor-based or offset-based pagination strategies
- Electric can efficiently handle tie-breaking with two targeted requests
- Better separation of concerns between filtering (`where`) and pagination (`cursor`/`offset`)
- `setWindow` correctly triggers backend loading for subsequent pages in multi-column orderBy queries
- Cursor state is properly reset after truncation, preventing stale cursor data from being used

- Ensure deterministic iteration order for collections and indexes. ([#958](https://github.com/TanStack/db/pull/958))

**SortedMap improvements:**
- Added key-based tie-breaking when values compare as equal, ensuring deterministic ordering
- Optimized to skip value comparison entirely when no comparator is provided (key-only sorting)
- Extracted `compareKeys` utility to `utils/comparison.ts` for reuse

**BTreeIndex improvements:**
- Keys within the same indexed value are now returned in deterministic sorted order
- Optimized with fast paths for empty sets and single-key sets to avoid unnecessary allocations

**CollectionStateManager changes:**
- Collections now always use `SortedMap` for `syncedData`, ensuring deterministic iteration order
- When no `compare` function is provided, entries are sorted by key only

This ensures that live queries with `orderBy` and `limit` produce stable, deterministic results even when multiple rows have equal sort values.

- Enhanced multi-column orderBy support with lazy loading and composite cursor optimization. ([#926](https://github.com/TanStack/db/pull/926))

**Changes:**
- Create index on first orderBy column even for multi-column orderBy queries, enabling lazy loading with first-column ordering
- Pass multi-column orderBy to loadSubset with precise composite cursors (e.g., `or(gt(col1, v1), and(eq(col1, v1), gt(col2, v2)))`) for backend optimization
- Use wide bounds (first column only) for local index operations to ensure no rows are missed
- Use precise composite cursor for sync layer loadSubset to minimize data transfer

**Benefits:**
- Multi-column orderBy queries with limit now support lazy loading (previously disabled)
- Sync implementations (like Electric) can optimize queries using composite indexes on the backend
- Local collection uses first-column index efficiently while backend gets precise cursor

- Updated dependencies [[`52c29fa`](https://github.com/TanStack/db/commit/52c29fa83b390ac26341dbf93e79ce0d59543686)]:
- @tanstack/db-ivm@0.1.14

## 0.5.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/db/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/db",
"version": "0.5.11",
"version": "0.5.12",
"description": "A reactive client store for building super fast apps on sync",
"author": "Kyle Mathews",
"license": "MIT",
Expand Down
37 changes: 37 additions & 0 deletions packages/electric-db-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# @tanstack/electric-db-collection

## 0.2.13

### Patch Changes

- Enhanced LoadSubsetOptions with separate cursor expressions and offset for flexible pagination. ([#960](https://github.com/TanStack/db/pull/960))

**⚠️ Breaking Change for Custom Sync Layers / Query Collections:**

`LoadSubsetOptions.where` no longer includes cursor expressions for pagination. If you have a custom sync layer or query collection that implements `loadSubset`, you must now handle pagination separately:
- **Cursor-based pagination:** Use the new `cursor` property (`cursor.whereFrom` and `cursor.whereCurrent`) and combine them with `where` yourself
- **Offset-based pagination:** Use the new `offset` property

Previously, cursor expressions were baked into the `where` clause. Now they are passed separately so sync layers can choose their preferred pagination strategy.

**Changes:**
- Added `CursorExpressions` type with `whereFrom`, `whereCurrent`, and optional `lastKey` properties
- Added `cursor` to `LoadSubsetOptions` for cursor-based pagination (separate from `where`)
- Added `offset` to `LoadSubsetOptions` for offset-based pagination support
- Electric sync layer now makes two parallel `requestSnapshot` calls when cursor is present:
- One for `whereCurrent` (all ties at boundary, no limit)
- One for `whereFrom` (rows after cursor, with limit)
- Query collection serialization now includes `offset` for query key generation
- Added `truncate` event to collections, emitted when synced data is truncated (e.g., after `must-refetch`)
- Fixed `setWindow` pagination: cursor expressions are now correctly built when paging through results
- Fixed offset tracking: `loadNextItems` now passes the correct window offset to prevent incorrect deduplication
- `CollectionSubscriber` now listens for `truncate` events to reset cursor tracking state

**Benefits:**
- Sync layers can choose between cursor-based or offset-based pagination strategies
- Electric can efficiently handle tie-breaking with two targeted requests
- Better separation of concerns between filtering (`where`) and pagination (`cursor`/`offset`)
- `setWindow` correctly triggers backend loading for subsequent pages in multi-column orderBy queries
- Cursor state is properly reset after truncation, preventing stale cursor data from being used

- Updated dependencies [[`b3b1940`](https://github.com/TanStack/db/commit/b3b194000d8efcc2c6cc45a663029dadc26f13f0), [`09da081`](https://github.com/TanStack/db/commit/09da081b420fc915d7f0dc566c6cdbbc78582435), [`86ad40c`](https://github.com/TanStack/db/commit/86ad40c6bc37b2f5d4ad24d06f72168ca4b96161)]:
- @tanstack/db@0.5.12

## 0.2.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/electric-db-collection/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/electric-db-collection",
"version": "0.2.12",
"version": "0.2.13",
"description": "ElectricSQL collection for TanStack DB",
"author": "Kyle Mathews",
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions packages/offline-transactions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/offline-transactions

## 1.0.2

### Patch Changes

- Updated dependencies [[`b3b1940`](https://github.com/TanStack/db/commit/b3b194000d8efcc2c6cc45a663029dadc26f13f0), [`09da081`](https://github.com/TanStack/db/commit/09da081b420fc915d7f0dc566c6cdbbc78582435), [`86ad40c`](https://github.com/TanStack/db/commit/86ad40c6bc37b2f5d4ad24d06f72168ca4b96161)]:
- @tanstack/db@0.5.12

## 1.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/offline-transactions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/offline-transactions",
"version": "1.0.1",
"version": "1.0.2",
"description": "Offline-first transaction capabilities for TanStack DB",
"author": "TanStack",
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions packages/powersync-db-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/powersync-db-collection

## 0.1.16

### Patch Changes

- Updated dependencies [[`b3b1940`](https://github.com/TanStack/db/commit/b3b194000d8efcc2c6cc45a663029dadc26f13f0), [`09da081`](https://github.com/TanStack/db/commit/09da081b420fc915d7f0dc566c6cdbbc78582435), [`86ad40c`](https://github.com/TanStack/db/commit/86ad40c6bc37b2f5d4ad24d06f72168ca4b96161)]:
- @tanstack/db@0.5.12

## 0.1.15

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/powersync-db-collection/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/powersync-db-collection",
"version": "0.1.15",
"version": "0.1.16",
"description": "PowerSync collection for TanStack DB",
"author": "POWERSYNC",
"license": "MIT",
Expand Down
37 changes: 37 additions & 0 deletions packages/query-db-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# @tanstack/query-db-collection

## 1.0.7

### Patch Changes

- Enhanced LoadSubsetOptions with separate cursor expressions and offset for flexible pagination. ([#960](https://github.com/TanStack/db/pull/960))

**⚠️ Breaking Change for Custom Sync Layers / Query Collections:**

`LoadSubsetOptions.where` no longer includes cursor expressions for pagination. If you have a custom sync layer or query collection that implements `loadSubset`, you must now handle pagination separately:
- **Cursor-based pagination:** Use the new `cursor` property (`cursor.whereFrom` and `cursor.whereCurrent`) and combine them with `where` yourself
- **Offset-based pagination:** Use the new `offset` property

Previously, cursor expressions were baked into the `where` clause. Now they are passed separately so sync layers can choose their preferred pagination strategy.

**Changes:**
- Added `CursorExpressions` type with `whereFrom`, `whereCurrent`, and optional `lastKey` properties
- Added `cursor` to `LoadSubsetOptions` for cursor-based pagination (separate from `where`)
- Added `offset` to `LoadSubsetOptions` for offset-based pagination support
- Electric sync layer now makes two parallel `requestSnapshot` calls when cursor is present:
- One for `whereCurrent` (all ties at boundary, no limit)
- One for `whereFrom` (rows after cursor, with limit)
- Query collection serialization now includes `offset` for query key generation
- Added `truncate` event to collections, emitted when synced data is truncated (e.g., after `must-refetch`)
- Fixed `setWindow` pagination: cursor expressions are now correctly built when paging through results
- Fixed offset tracking: `loadNextItems` now passes the correct window offset to prevent incorrect deduplication
- `CollectionSubscriber` now listens for `truncate` events to reset cursor tracking state

**Benefits:**
- Sync layers can choose between cursor-based or offset-based pagination strategies
- Electric can efficiently handle tie-breaking with two targeted requests
- Better separation of concerns between filtering (`where`) and pagination (`cursor`/`offset`)
- `setWindow` correctly triggers backend loading for subsequent pages in multi-column orderBy queries
- Cursor state is properly reset after truncation, preventing stale cursor data from being used

- Updated dependencies [[`b3b1940`](https://github.com/TanStack/db/commit/b3b194000d8efcc2c6cc45a663029dadc26f13f0), [`09da081`](https://github.com/TanStack/db/commit/09da081b420fc915d7f0dc566c6cdbbc78582435), [`86ad40c`](https://github.com/TanStack/db/commit/86ad40c6bc37b2f5d4ad24d06f72168ca4b96161)]:
- @tanstack/db@0.5.12

## 1.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/query-db-collection/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/query-db-collection",
"version": "1.0.6",
"version": "1.0.7",
"description": "TanStack Query collection for TanStack DB",
"author": "Kyle Mathews",
"license": "MIT",
Expand Down
7 changes: 7 additions & 0 deletions packages/react-db/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/react-db

## 0.1.56

### Patch Changes

- Updated dependencies [[`b3b1940`](https://github.com/TanStack/db/commit/b3b194000d8efcc2c6cc45a663029dadc26f13f0), [`09da081`](https://github.com/TanStack/db/commit/09da081b420fc915d7f0dc566c6cdbbc78582435), [`86ad40c`](https://github.com/TanStack/db/commit/86ad40c6bc37b2f5d4ad24d06f72168ca4b96161)]:
- @tanstack/db@0.5.12

## 0.1.55

### Patch Changes
Expand Down
Loading