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
431 changes: 422 additions & 9 deletions docs/framework/react/reference/functions/useLiveQuery.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/framework/react/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ title: "@tanstack/react-db"

## Type Aliases

- [ConditionalUseLiveQueryConfig](type-aliases/ConditionalUseLiveQueryConfig.md)
- [DbProviderProps](type-aliases/DbProviderProps.md)
- [HydrationBoundaryProps](type-aliases/HydrationBoundaryProps.md)
- [LiveQueryKey](type-aliases/LiveQueryKey.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
id: ConditionalUseLiveQueryConfig
title: ConditionalUseLiveQueryConfig
---

# Type Alias: ConditionalUseLiveQueryConfig\<TContext\>

```ts
type ConditionalUseLiveQueryConfig<TContext> = UseLiveQueryConfigOptions<TContext> & object;
```

Defined in: [useLiveQuery.ts:74](https://github.com/TanStack/db/blob/main/packages/react-db/src/useLiveQuery.ts#L74)

## Type Declaration

### query

```ts
query:
| ConfiguredQueryBuilder<TContext>
| (q) => ConfiguredQueryBuilder<TContext> | undefined | null;
```

## Type Parameters

### TContext

`TContext` *extends* `Context`
24 changes: 2 additions & 22 deletions docs/framework/react/reference/type-aliases/UseLiveQueryConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,10 @@ title: UseLiveQueryConfig
# Type Alias: UseLiveQueryConfig\<TContext\>

```ts
type UseLiveQueryConfig<TContext> = LiveQueryCollectionConfig<TContext> & object;
type UseLiveQueryConfig<TContext> = UseLiveQueryConfigOptions<TContext> & Pick<LiveQueryCollectionConfig<TContext>, "query">;
```

Defined in: [useLiveQuery.ts:51](https://github.com/TanStack/db/blob/main/packages/react-db/src/useLiveQuery.ts#L51)

## Type Declaration

### client?

```ts
optional client: DbClient;
```

Override the nearest DbProvider for this query.

### queryKey?

```ts
optional queryKey: LiveQueryKey;
```

Explicit identity for queries that contain opaque functional variants or
are hot enough that deriving identity from structured IR is too expensive.
Structured queries should omit this so DB can derive identity directly.
Defined in: [useLiveQuery.ts:70](https://github.com/TanStack/db/blob/main/packages/react-db/src/useLiveQuery.ts#L70)

## Type Parameters

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/classes/AggregateFunctionNotInSelectError.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: AggregateFunctionNotInSelectError

# Class: AggregateFunctionNotInSelectError

Defined in: [packages/db/src/errors.ts:651](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L651)
Defined in: [packages/db/src/errors.ts:661](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L661)

## Extends

Expand All @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:651](https://github.com/TanStack/db/blob/
new AggregateFunctionNotInSelectError(functionName): AggregateFunctionNotInSelectError;
```

Defined in: [packages/db/src/errors.ts:652](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L652)
Defined in: [packages/db/src/errors.ts:662](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L662)

#### Parameters

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/classes/AggregateNotSupportedError.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: AggregateNotSupportedError

# Class: AggregateNotSupportedError

Defined in: [packages/db/src/errors.ts:767](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L767)
Defined in: [packages/db/src/errors.ts:777](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L777)

Error thrown when aggregate expressions are used outside of a GROUP BY context.

Expand All @@ -21,7 +21,7 @@ Error thrown when aggregate expressions are used outside of a GROUP BY context.
new AggregateNotSupportedError(): AggregateNotSupportedError;
```

Defined in: [packages/db/src/errors.ts:768](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L768)
Defined in: [packages/db/src/errors.ts:778](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L778)

#### Returns

Expand Down
53 changes: 29 additions & 24 deletions docs/reference/classes/BaseQueryBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: BaseQueryBuilder

# Class: BaseQueryBuilder\<TContext\>

Defined in: [packages/db/src/query/builder/index.ts:84](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L84)
Defined in: [packages/db/src/query/builder/index.ts:135](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L135)

## Type Parameters

Expand All @@ -21,7 +21,7 @@ Defined in: [packages/db/src/query/builder/index.ts:84](https://github.com/TanSt
new BaseQueryBuilder<TContext>(query, resolveCollection?): BaseQueryBuilder<TContext>;
```

Defined in: [packages/db/src/query/builder/index.ts:87](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L87)
Defined in: [packages/db/src/query/builder/index.ts:138](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L138)

#### Parameters

Expand All @@ -47,7 +47,7 @@ Defined in: [packages/db/src/query/builder/index.ts:87](https://github.com/TanSt
get fn(): object;
```

Defined in: [packages/db/src/query/builder/index.ts:872](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L872)
Defined in: [packages/db/src/query/builder/index.ts:923](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L923)

Functional variants of the query builder
These are imperative function that are called for ery row.
Expand Down Expand Up @@ -102,7 +102,7 @@ query
###### select()

```ts
select<TFuncSelectResult>(callback): QueryBuilder<WithResult<TContext, TFuncSelectResult>>;
select<TFuncSelectResult>(callback): FnSelectQueryResult<TContext, TFuncSelectResult>;
```

Select fields using a function that operates on each row
Expand All @@ -124,7 +124,7 @@ A function that receives a row and returns the selected value

###### Returns

[`QueryBuilder`](../type-aliases/QueryBuilder.md)\<[`WithResult`](../type-aliases/WithResult.md)\<`TContext`, `TFuncSelectResult`\>\>
`FnSelectQueryResult`\<`TContext`, `TFuncSelectResult`\>

A QueryBuilder with functional selection applied

Expand All @@ -140,6 +140,11 @@ query
}))
```

Child query builders, query expressions, and helpers such as eq(),
toArray(), and materialize() cannot be returned from fn.select(). Use
them as fields in select() so the compiler can add them to the query
graph.

###### where()

```ts
Expand Down Expand Up @@ -180,7 +185,7 @@ query
_getQuery(): QueryIR;
```

Defined in: [packages/db/src/query/builder/index.ts:959](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L959)
Defined in: [packages/db/src/query/builder/index.ts:1015](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L1015)

#### Returns

Expand All @@ -194,7 +199,7 @@ Defined in: [packages/db/src/query/builder/index.ts:959](https://github.com/TanS
distinct(): QueryBuilder<TContext>;
```

Defined in: [packages/db/src/query/builder/index.ts:805](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L805)
Defined in: [packages/db/src/query/builder/index.ts:856](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L856)

Specify that the query should return distinct rows.
Deduplicates rows based on the selected columns.
Expand Down Expand Up @@ -223,7 +228,7 @@ query
findOne(): QueryBuilder<TContext & SingleResult>;
```

Defined in: [packages/db/src/query/builder/index.ts:825](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L825)
Defined in: [packages/db/src/query/builder/index.ts:876](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L876)

Specify that the query should return a single result

Expand Down Expand Up @@ -251,7 +256,7 @@ query
from<TSource>(source): QueryBuilder<ContextFromSource<TSource>>;
```

Defined in: [packages/db/src/query/builder/index.ts:197](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L197)
Defined in: [packages/db/src/query/builder/index.ts:248](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L248)

Specify the source table or subquery for the query

Expand Down Expand Up @@ -294,7 +299,7 @@ query.from({ activeUsers })
fullJoin<TSource>(source, onCallback): QueryBuilder<MergeContextWithJoinType<TContext, SchemaFromSource<TSource>, "full">>;
```

Defined in: [packages/db/src/query/builder/index.ts:432](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L432)
Defined in: [packages/db/src/query/builder/index.ts:483](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L483)

Perform a FULL JOIN with another table or subquery

Expand Down Expand Up @@ -341,7 +346,7 @@ query
groupBy(callback): QueryBuilder<TContext>;
```

Defined in: [packages/db/src/query/builder/index.ts:727](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L727)
Defined in: [packages/db/src/query/builder/index.ts:778](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L778)

Group rows by one or more columns for aggregation

Expand Down Expand Up @@ -390,7 +395,7 @@ query
having(callback): QueryBuilder<TContext>;
```

Defined in: [packages/db/src/query/builder/index.ts:526](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L526)
Defined in: [packages/db/src/query/builder/index.ts:577](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L577)

Filter grouped rows based on aggregate conditions

Expand Down Expand Up @@ -439,7 +444,7 @@ query
innerJoin<TSource>(source, onCallback): QueryBuilder<MergeContextWithJoinType<TContext, SchemaFromSource<TSource>, "inner">>;
```

Defined in: [packages/db/src/query/builder/index.ts:406](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L406)
Defined in: [packages/db/src/query/builder/index.ts:457](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L457)

Perform an INNER JOIN with another table or subquery

Expand Down Expand Up @@ -489,7 +494,7 @@ join<TSource, TJoinType>(
type): QueryBuilder<MergeContextWithJoinType<TContext, SchemaFromSource<TSource>, TJoinType>>;
```

Defined in: [packages/db/src/query/builder/index.ts:284](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L284)
Defined in: [packages/db/src/query/builder/index.ts:335](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L335)

Join another table or subquery to the current query

Expand Down Expand Up @@ -557,7 +562,7 @@ query
leftJoin<TSource>(source, onCallback): QueryBuilder<MergeContextWithJoinType<TContext, SchemaFromSource<TSource>, "left">>;
```

Defined in: [packages/db/src/query/builder/index.ts:354](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L354)
Defined in: [packages/db/src/query/builder/index.ts:405](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L405)

Perform a LEFT JOIN with another table or subquery

Expand Down Expand Up @@ -604,7 +609,7 @@ query
limit(count): QueryBuilder<TContext>;
```

Defined in: [packages/db/src/query/builder/index.ts:760](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L760)
Defined in: [packages/db/src/query/builder/index.ts:811](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L811)

Limit the number of rows returned by the query
`orderBy` is required for `limit`
Expand Down Expand Up @@ -641,7 +646,7 @@ query
offset(count): QueryBuilder<TContext>;
```

Defined in: [packages/db/src/query/builder/index.ts:784](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L784)
Defined in: [packages/db/src/query/builder/index.ts:835](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L835)

Skip a number of rows before returning results
`orderBy` is required for `offset`
Expand Down Expand Up @@ -679,7 +684,7 @@ query
orderBy(callback, options): QueryBuilder<TContext>;
```

Defined in: [packages/db/src/query/builder/index.ts:651](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L651)
Defined in: [packages/db/src/query/builder/index.ts:702](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L702)

Sort the query results by one or more columns

Expand Down Expand Up @@ -729,7 +734,7 @@ query
rightJoin<TSource>(source, onCallback): QueryBuilder<MergeContextWithJoinType<TContext, SchemaFromSource<TSource>, "right">>;
```

Defined in: [packages/db/src/query/builder/index.ts:380](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L380)
Defined in: [packages/db/src/query/builder/index.ts:431](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L431)

Perform a RIGHT JOIN with another table or subquery

Expand Down Expand Up @@ -778,7 +783,7 @@ query
select<TSelectObject>(callback): QueryBuilder<WithResult<TContext, ResultTypeFromSelect<TSelectObject>>>;
```

Defined in: [packages/db/src/query/builder/index.ts:592](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L592)
Defined in: [packages/db/src/query/builder/index.ts:643](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L643)

Select specific columns or computed values from the query

Expand Down Expand Up @@ -837,7 +842,7 @@ query
select<TSelectValue>(callback): QueryBuilder<WithResult<TContext, ResultTypeFromSelectValue<TSelectValue>>>;
```

Defined in: [packages/db/src/query/builder/index.ts:597](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L597)
Defined in: [packages/db/src/query/builder/index.ts:648](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L648)

Select specific columns or computed values from the query

Expand Down Expand Up @@ -900,7 +905,7 @@ query
unionAll<TSource>(source): QueryBuilder<ContextFromUnionSource<TSource>>;
```

Defined in: [packages/db/src/query/builder/index.ts:223](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L223)
Defined in: [packages/db/src/query/builder/index.ts:274](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L274)

Union multiple independent source streams in one query.

Expand Down Expand Up @@ -940,7 +945,7 @@ query
unionAll<TBranches>(...branches): QueryBuilder<ContextFromUnionBranches<TBranches>>;
```

Defined in: [packages/db/src/query/builder/index.ts:226](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L226)
Defined in: [packages/db/src/query/builder/index.ts:277](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L277)

Union multiple independent source streams in one query.

Expand Down Expand Up @@ -980,7 +985,7 @@ query
where(callback): QueryBuilder<TContext>;
```

Defined in: [packages/db/src/query/builder/index.ts:471](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L471)
Defined in: [packages/db/src/query/builder/index.ts:522](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L522)

Filter rows based on a condition

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: CannotCombineEmptyExpressionListError

# Class: CannotCombineEmptyExpressionListError

Defined in: [packages/db/src/errors.ts:730](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L730)
Defined in: [packages/db/src/errors.ts:740](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L740)

## Extends

Expand All @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:730](https://github.com/TanStack/db/blob/
new CannotCombineEmptyExpressionListError(): CannotCombineEmptyExpressionListError;
```

Defined in: [packages/db/src/errors.ts:731](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L731)
Defined in: [packages/db/src/errors.ts:741](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L741)

#### Returns

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/classes/CollectionInputNotFoundError.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: CollectionInputNotFoundError

# Class: CollectionInputNotFoundError

Defined in: [packages/db/src/errors.ts:511](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L511)
Defined in: [packages/db/src/errors.ts:521](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L521)

Error thrown when a collection input stream is not found during query compilation.
In self-joins, each alias (e.g., 'employee', 'manager') requires its own input stream.
Expand All @@ -25,7 +25,7 @@ new CollectionInputNotFoundError(
availableKeys?): CollectionInputNotFoundError;
```

Defined in: [packages/db/src/errors.ts:512](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L512)
Defined in: [packages/db/src/errors.ts:522](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L522)

#### Parameters

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/classes/DuplicateAliasInSubqueryError.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: DuplicateAliasInSubqueryError

# Class: DuplicateAliasInSubqueryError

Defined in: [packages/db/src/errors.ts:532](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L532)
Defined in: [packages/db/src/errors.ts:542](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L542)

Error thrown when a subquery uses the same alias as its parent query.
This causes issues because parent and subquery would share the same input streams,
Expand All @@ -23,7 +23,7 @@ leading to empty results or incorrect data (aggregation cross-leaking).
new DuplicateAliasInSubqueryError(alias, parentAliases): DuplicateAliasInSubqueryError;
```

Defined in: [packages/db/src/errors.ts:533](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L533)
Defined in: [packages/db/src/errors.ts:543](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L543)

#### Parameters

Expand Down
Loading