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
50 changes: 0 additions & 50 deletions .changeset/enable-nested-auto-index.md

This file was deleted.

10 changes: 0 additions & 10 deletions .changeset/optimize-multiple-where-clauses.md

This file was deleted.

49 changes: 0 additions & 49 deletions .changeset/paced-mutations.md

This file was deleted.

8 changes: 8 additions & 0 deletions examples/angular/todos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# todos

## 0.0.17

### Patch Changes

- Updated dependencies [[`979a66f`](https://github.com/TanStack/db/commit/979a66f2f6eff0ffe44dfde7c67feea933ee6110), [`f8a979b`](https://github.com/TanStack/db/commit/f8a979ba3aa90ac7e85f7a065fc050bda6589b4b), [`cb25623`](https://github.com/TanStack/db/commit/cb256234c9cd8df7771808b147e5afc2be56f51f)]:
- @tanstack/db@0.4.16
- @tanstack/angular-db@0.1.21

## 0.0.16

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/angular/todos/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "todos",
"version": "0.0.16",
"version": "0.0.17",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down
9 changes: 9 additions & 0 deletions examples/react/paced-mutations-demo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @tanstack/db-example-paced-mutations-demo

## 0.0.2

### Patch Changes

- Updated dependencies [[`979a66f`](https://github.com/TanStack/db/commit/979a66f2f6eff0ffe44dfde7c67feea933ee6110), [`f8a979b`](https://github.com/TanStack/db/commit/f8a979ba3aa90ac7e85f7a065fc050bda6589b4b), [`cb25623`](https://github.com/TanStack/db/commit/cb256234c9cd8df7771808b147e5afc2be56f51f)]:
- @tanstack/db@0.4.16
- @tanstack/react-db@0.1.38
2 changes: 1 addition & 1 deletion examples/react/paced-mutations-demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tanstack/db-example-paced-mutations-demo",
"version": "0.0.1",
"version": "0.0.2",
"private": true,
"type": "module",
"scripts": {
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.16",
"@tanstack/query-core": "^5.90.5",
"@tanstack/query-db-collection": "^0.2.38",
"@tanstack/react-db": "^0.1.37",
"@tanstack/query-db-collection": "^0.2.39",
"@tanstack/react-db": "^0.1.38",
"@tanstack/react-router": "^1.133.32",
"@tanstack/react-router-devtools": "^1.133.32",
"@tanstack/react-router-with-query": "^1.130.17",
Expand Down
10 changes: 10 additions & 0 deletions examples/react/todo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# examples/react/todo

## 0.1.18

### Patch Changes

- Updated dependencies [[`cb25623`](https://github.com/TanStack/db/commit/cb256234c9cd8df7771808b147e5afc2be56f51f)]:
- @tanstack/react-db@0.1.38
- @tanstack/electric-db-collection@0.1.40
- @tanstack/query-db-collection@0.2.39
- @tanstack/trailbase-db-collection@0.1.38

## 0.1.17

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/react/todo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tanstack/db-example-react-todo",
"private": true,
"version": "0.1.17",
"version": "0.1.18",
"dependencies": {
"@tanstack/electric-db-collection": "workspace:^",
"@tanstack/query-core": "^5.90.5",
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.21

### Patch Changes

- Updated dependencies [[`979a66f`](https://github.com/TanStack/db/commit/979a66f2f6eff0ffe44dfde7c67feea933ee6110), [`f8a979b`](https://github.com/TanStack/db/commit/f8a979ba3aa90ac7e85f7a065fc050bda6589b4b), [`cb25623`](https://github.com/TanStack/db/commit/cb256234c9cd8df7771808b147e5afc2be56f51f)]:
- @tanstack/db@0.4.16

## 0.1.20

### 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,7 +1,7 @@
{
"name": "@tanstack/angular-db",
"description": "Angular integration for @tanstack/db",
"version": "0.1.20",
"version": "0.1.21",
"author": "Ethan McDaniel",
"license": "MIT",
"repository": {
Expand Down
96 changes: 96 additions & 0 deletions packages/db/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,101 @@
# @tanstack/db

## 0.4.16

### Patch Changes

- Enable auto-indexing for nested field paths ([#728](https://github.com/TanStack/db/pull/728))

Previously, auto-indexes were only created for top-level fields. Queries filtering on nested fields like `vehicleDispatch.date` or `profile.score` were forced to perform full table scans, causing significant performance issues.

Now, auto-indexes are automatically created for nested field paths of any depth when using `eq()`, `gt()`, `gte()`, `lt()`, `lte()`, or `in()` operations.

**Performance Impact:**

Before this fix, filtering on nested fields resulted in expensive full scans:
- Query time: ~353ms for 39 executions (from issue #727)
- "graph run" and "d2ts join" operations dominated execution time

After this fix, nested field queries use indexes:
- Query time: Sub-millisecond (typical indexed lookup)
- Proper index utilization verified through query optimizer

**Example:**

```typescript
const collection = createCollection({
getKey: (item) => item.id,
autoIndex: "eager", // default
// ... sync config
})

// These now automatically create and use indexes:
collection.subscribeChanges((items) => console.log(items), {
whereExpression: eq(row.vehicleDispatch?.date, "2024-01-01"),
})

collection.subscribeChanges((items) => console.log(items), {
whereExpression: gt(row.profile?.stats.rating, 4.5),
})
```

**Index Naming:**

Auto-indexes for nested paths use the format `auto:field.path` to avoid naming conflicts:
- `auto:status` for top-level field `status`
- `auto:profile.score` for nested field `profile.score`
- `auto:metadata.stats.views` for deeply nested field `metadata.stats.views`

Fixes #727

- Fixed performance issue where using multiple `.where()` calls created multiple filter operators in the query pipeline. The optimizer now implements the missing final step (step 3) of combining remaining WHERE clauses into a single AND expression. This applies to both queries with and without joins: ([#732](https://github.com/TanStack/db/pull/732))
- Queries without joins: Multiple WHERE clauses are now combined before compilation
- Queries with joins: Remaining WHERE clauses after predicate pushdown are combined

This reduces filter operators from N to 1, making chained `.where()` calls perform identically to using a single `.where()` with `and()`.

- Add paced mutations with pluggable timing strategies ([#704](https://github.com/TanStack/db/pull/704))

Introduces a new paced mutations system that enables optimistic mutations with pluggable timing strategies. This provides fine-grained control over when and how mutations are persisted to the backend. Powered by [TanStack Pacer](https://github.com/TanStack/pacer).

**Key Design:**
- **Debounce/Throttle**: Only one pending transaction (collecting mutations) and one persisting transaction (writing to backend) at a time. Multiple rapid mutations automatically merge together.
- **Queue**: Each mutation creates a separate transaction, guaranteed to run in the order they're made (FIFO by default, configurable to LIFO).

**Core Features:**
- **Pluggable Strategy System**: Choose from debounce, queue, or throttle strategies to control mutation timing
- **Auto-merging Mutations**: Multiple rapid mutations on the same item automatically merge for efficiency (debounce/throttle only)
- **Transaction Management**: Full transaction lifecycle tracking (pending → persisting → completed/failed)
- **React Hook**: `usePacedMutations` for easy integration in React applications

**Available Strategies:**
- `debounceStrategy`: Wait for inactivity before persisting. Only final state is saved. (ideal for auto-save, search-as-you-type)
- `queueStrategy`: Each mutation becomes a separate transaction, processed sequentially in order (defaults to FIFO, configurable to LIFO). All mutations are guaranteed to persist. (ideal for sequential workflows, rate-limited APIs)
- `throttleStrategy`: Ensure minimum spacing between executions. Mutations between executions are merged. (ideal for analytics, progress updates)

**Example Usage:**

```ts
import { usePacedMutations, debounceStrategy } from "@tanstack/react-db"

const mutate = usePacedMutations({
mutationFn: async ({ transaction }) => {
await api.save(transaction.mutations)
},
strategy: debounceStrategy({ wait: 500 }),
})

// Trigger a mutation
const tx = mutate(() => {
collection.update(id, (draft) => {
draft.value = newValue
})
})

// Optionally await persistence
await tx.isPersisted.promise
```

## 0.4.15

### 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,7 +1,7 @@
{
"name": "@tanstack/db",
"description": "A reactive client store for building super fast apps on sync",
"version": "0.4.15",
"version": "0.4.16",
"dependencies": {
"@standard-schema/spec": "^1.0.0",
"@tanstack/db-ivm": "workspace:*",
Expand Down
7 changes: 7 additions & 0 deletions packages/electric-db-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/electric-db-collection

## 0.1.40

### Patch Changes

- Updated dependencies [[`979a66f`](https://github.com/TanStack/db/commit/979a66f2f6eff0ffe44dfde7c67feea933ee6110), [`f8a979b`](https://github.com/TanStack/db/commit/f8a979ba3aa90ac7e85f7a065fc050bda6589b4b), [`cb25623`](https://github.com/TanStack/db/commit/cb256234c9cd8df7771808b147e5afc2be56f51f)]:
- @tanstack/db@0.4.16

## 0.1.39

### 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,7 +1,7 @@
{
"name": "@tanstack/electric-db-collection",
"description": "ElectricSQL collection for TanStack DB",
"version": "0.1.39",
"version": "0.1.40",
"dependencies": {
"@electric-sql/client": "^1.1.0",
"@standard-schema/spec": "^1.0.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/query-db-collection/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @tanstack/query-db-collection

## 0.2.39

### Patch Changes

- Updated dependencies [[`979a66f`](https://github.com/TanStack/db/commit/979a66f2f6eff0ffe44dfde7c67feea933ee6110), [`f8a979b`](https://github.com/TanStack/db/commit/f8a979ba3aa90ac7e85f7a065fc050bda6589b4b), [`cb25623`](https://github.com/TanStack/db/commit/cb256234c9cd8df7771808b147e5afc2be56f51f)]:
- @tanstack/db@0.4.16

## 0.2.38

### 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,7 +1,7 @@
{
"name": "@tanstack/query-db-collection",
"description": "TanStack Query collection for TanStack DB",
"version": "0.2.38",
"version": "0.2.39",
"dependencies": {
"@standard-schema/spec": "^1.0.0",
"@tanstack/db": "workspace:*"
Expand Down
Loading