diff --git a/docs/framework/angular/reference/interfaces/InjectLiveQueryResult.md b/docs/framework/angular/reference/interfaces/InjectLiveQueryResult.md index 523f0dad9..066d6b5ba 100644 --- a/docs/framework/angular/reference/interfaces/InjectLiveQueryResult.md +++ b/docs/framework/angular/reference/interfaces/InjectLiveQueryResult.md @@ -22,8 +22,8 @@ Contains reactive signals for the query state and data. ```ts collection: Signal< - | Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, { -}, StandardSchemaV1, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }> + | Collection<{ [K in string | number | symbol]: ResultValue[K] }, string | number, { +}, StandardSchemaV1, { [K in string | number | symbol]: ResultValue[K] }> | null>; ``` @@ -108,7 +108,7 @@ A signal indicating whether the collection is ready ### state ```ts -state: Signal>; +state: Signal[K] }>>; ``` Defined in: [index.ts:34](https://github.com/TanStack/db/blob/main/packages/angular-db/src/index.ts#L34) diff --git a/docs/framework/react/reference/functions/useLiveQuery.md b/docs/framework/react/reference/functions/useLiveQuery.md index 84162b674..accc95e0f 100644 --- a/docs/framework/react/reference/functions/useLiveQuery.md +++ b/docs/framework/react/reference/functions/useLiveQuery.md @@ -44,7 +44,7 @@ Object with reactive data, state, and status information #### collection ```ts -collection: Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, { +collection: Collection<{ [K in string | number | symbol]: ResultValue[K] }, string | number, { }>; ``` @@ -93,7 +93,7 @@ isReady: boolean; #### state ```ts -state: Map; +state: Map[K] }>; ``` #### status @@ -202,8 +202,8 @@ Object with reactive data, state, and status information ```ts collection: - | Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, { -}, StandardSchemaV1, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }> + | Collection<{ [K in string | number | symbol]: ResultValue[K] }, string | number, { +}, StandardSchemaV1, { [K in string | number | symbol]: ResultValue[K] }> | undefined; ``` @@ -253,7 +253,7 @@ isReady: boolean; ```ts state: - | Map + | Map[K] }> | undefined; ``` @@ -344,7 +344,7 @@ Create a live query using a query function #### queryFn (`q`) => - \| `LiveQueryCollectionConfig`\<`TContext`, \{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \} & `object`\> + \| `LiveQueryCollectionConfig`\<`TContext`, `RootQueryResult`\<`TContext`\>\> \| `null` \| `undefined` @@ -366,8 +366,8 @@ Object with reactive data, state, and status information ```ts collection: - | Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, { -}, StandardSchemaV1, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }> + | Collection<{ [K in string | number | symbol]: ResultValue[K] }, string | number, { +}, StandardSchemaV1, { [K in string | number | symbol]: ResultValue[K] }> | undefined; ``` @@ -417,7 +417,7 @@ isReady: boolean; ```ts state: - | Map + | Map[K] }> | undefined; ``` @@ -690,7 +690,7 @@ Create a live query using a query function (`q`) => \| `QueryBuilder`\<`TContext`\> - \| `LiveQueryCollectionConfig`\<`TContext`, \{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \} & `object`\> + \| `LiveQueryCollectionConfig`\<`TContext`, `RootQueryResult`\<`TContext`\>\> \| `Collection`\<`TResult`, `TKey`, `TUtils`, `StandardSchemaV1`\<`unknown`, `unknown`\>, `TResult`\> \| `null` \| `undefined` @@ -714,8 +714,8 @@ Object with reactive data, state, and status information ```ts collection: | Collection, TResult> - | Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, { -}, StandardSchemaV1, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }> + | Collection<{ [K in string | number | symbol]: ResultValue[K] }, string | number, { +}, StandardSchemaV1, { [K in string | number | symbol]: ResultValue[K] }> | undefined; ``` @@ -765,7 +765,7 @@ isReady: boolean; ```ts state: - | Map + | Map[K] }> | Map | undefined; ``` @@ -875,7 +875,7 @@ Object with reactive data, state, and status information #### collection ```ts -collection: Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, { +collection: Collection<{ [K in string | number | symbol]: ResultValue[K] }, string | number, { }>; ``` @@ -924,7 +924,7 @@ isReady: boolean; #### state ```ts -state: Map; +state: Map[K] }>; ``` #### status diff --git a/docs/framework/react/reference/functions/useLiveQueryEffect.md b/docs/framework/react/reference/functions/useLiveQueryEffect.md new file mode 100644 index 000000000..5baa17147 --- /dev/null +++ b/docs/framework/react/reference/functions/useLiveQueryEffect.md @@ -0,0 +1,61 @@ +--- +id: useLiveQueryEffect +title: useLiveQueryEffect +--- + +# Function: useLiveQueryEffect() + +```ts +function useLiveQueryEffect(config, deps): void; +``` + +Defined in: [useLiveQueryEffect.ts:30](https://github.com/TanStack/db/blob/main/packages/react-db/src/useLiveQueryEffect.ts#L30) + +React hook for creating a reactive effect that fires handlers when rows +enter, exit, or update within a query result. + +The effect is created on mount and disposed on unmount. If `deps` change, +the previous effect is disposed and a new one is created. + +## Type Parameters + +### TRow + +`TRow` *extends* `object` = `Record`\<`string`, `unknown`\> + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + +## Parameters + +### config + +`EffectConfig`\<`TRow`, `TKey`\> + +### deps + +`DependencyList` = `[]` + +## Returns + +`void` + +## Example + +```tsx +function ChatComponent() { + useLiveQueryEffect( + { + query: (q) => q.from({ msg: messages }).where(({ msg }) => eq(msg.role, 'user')), + skipInitial: true, + onEnter: async (event) => { + await generateResponse(event.value) + }, + }, + [] + ) + + return
...
+} +``` diff --git a/docs/framework/react/reference/functions/useLiveSuspenseQuery.md b/docs/framework/react/reference/functions/useLiveSuspenseQuery.md index 94c00a9fd..83ae3a93e 100644 --- a/docs/framework/react/reference/functions/useLiveSuspenseQuery.md +++ b/docs/framework/react/reference/functions/useLiveSuspenseQuery.md @@ -44,7 +44,7 @@ Object with reactive data and state - data is guaranteed to be defined #### collection ```ts -collection: Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, { +collection: Collection<{ [K in string | number | symbol]: ResultValue[K] }, string | number, { }>; ``` @@ -57,7 +57,7 @@ data: InferResultType; #### state ```ts -state: Map; +state: Map[K] }>; ``` ### Throws @@ -198,7 +198,7 @@ Object with reactive data and state - data is guaranteed to be defined #### collection ```ts -collection: Collection<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, string | number, { +collection: Collection<{ [K in string | number | symbol]: ResultValue[K] }, string | number, { }>; ``` @@ -211,7 +211,7 @@ data: InferResultType; #### state ```ts -state: Map; +state: Map[K] }>; ``` ### Throws diff --git a/docs/framework/react/reference/index.md b/docs/framework/react/reference/index.md index a35d6af9f..07d892ce4 100644 --- a/docs/framework/react/reference/index.md +++ b/docs/framework/react/reference/index.md @@ -15,5 +15,6 @@ title: "@tanstack/react-db" - [useLiveInfiniteQuery](functions/useLiveInfiniteQuery.md) - [useLiveQuery](functions/useLiveQuery.md) +- [useLiveQueryEffect](functions/useLiveQueryEffect.md) - [useLiveSuspenseQuery](functions/useLiveSuspenseQuery.md) - [usePacedMutations](functions/usePacedMutations.md) diff --git a/docs/framework/solid/reference/functions/useLiveQuery.md b/docs/framework/solid/reference/functions/useLiveQuery.md index 74044531d..a4e51b792 100644 --- a/docs/framework/solid/reference/functions/useLiveQuery.md +++ b/docs/framework/solid/reference/functions/useLiveQuery.md @@ -8,10 +8,10 @@ title: useLiveQuery ## Call Signature ```ts -function useLiveQuery(queryFn): Accessor<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }[]> & object; +function useLiveQuery(queryFn): Accessor> & object; ``` -Defined in: [useLiveQuery.ts:98](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L98) +Defined in: [useLiveQuery.ts:102](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L102) Create a live query using a query function @@ -108,10 +108,10 @@ return ( ## Call Signature ```ts -function useLiveQuery(queryFn): Accessor<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }[]> & object; +function useLiveQuery(queryFn): Accessor> & object; ``` -Defined in: [useLiveQuery.ts:117](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L117) +Defined in: [useLiveQuery.ts:121](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L121) Create a live query using a query function @@ -208,10 +208,10 @@ return ( ## Call Signature ```ts -function useLiveQuery(config): Accessor<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }[]> & object; +function useLiveQuery(config): Accessor> & object; ``` -Defined in: [useLiveQuery.ts:178](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L178) +Defined in: [useLiveQuery.ts:182](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L182) Create a live query using configuration object @@ -225,7 +225,7 @@ Create a live query using configuration object #### config -`Accessor`\<`LiveQueryCollectionConfig`\<`TContext`, \{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \} & `object`\>\> +`Accessor`\<`LiveQueryCollectionConfig`\<`TContext`, `RootQueryResult`\<`TContext`\>\>\> Configuration object with query and options @@ -280,7 +280,7 @@ return ( function useLiveQuery(liveQueryCollection): Accessor & object; ``` -Defined in: [useLiveQuery.ts:232](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L232) +Defined in: [useLiveQuery.ts:236](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L236) Subscribe to an existing live query collection @@ -302,7 +302,7 @@ Subscribe to an existing live query collection #### liveQueryCollection -`Accessor`\<`Collection`\<`TResult`, `TKey`, `TUtils`, `StandardSchemaV1`\<`unknown`, `unknown`\>, `TResult`\>\> +`Accessor`\<`Collection`\<`TResult`, `TKey`, `TUtils`, `StandardSchemaV1`\<`unknown`, `unknown`\>, `TResult`\> & `NonSingleResult`\> Pre-created live query collection to subscribe to @@ -345,3 +345,109 @@ return ( ) ``` + +## Call Signature + +```ts +function useLiveQuery(liveQueryCollection): Accessor & object; +``` + +Defined in: [useLiveQuery.ts:261](https://github.com/TanStack/db/blob/main/packages/solid-db/src/useLiveQuery.ts#L261) + +Create a live query using a query function + +### Type Parameters + +#### TResult + +`TResult` *extends* `object` + +#### TKey + +`TKey` *extends* `string` \| `number` + +#### TUtils + +`TUtils` *extends* `Record`\<`string`, `any`\> + +### Parameters + +#### liveQueryCollection + +`Accessor`\<`Collection`\<`TResult`, `TKey`, `TUtils`, `StandardSchemaV1`\<`unknown`, `unknown`\>, `TResult`\> & `SingleResult`\> + +### Returns + +Accessor that returns data with Suspense support, with state and status information as properties + +### Examples + +```ts +// Basic query with object syntax +const todosQuery = useLiveQuery((q) => + q.from({ todos: todosCollection }) + .where(({ todos }) => eq(todos.completed, false)) + .select(({ todos }) => ({ id: todos.id, text: todos.text })) +) +``` + +```ts +// With dependencies that trigger re-execution +const todosQuery = useLiveQuery( + (q) => q.from({ todos: todosCollection }) + .where(({ todos }) => gt(todos.priority, minPriority())), +) +``` + +```ts +// Join pattern +const personIssues = useLiveQuery((q) => + q.from({ issues: issueCollection }) + .join({ persons: personCollection }, ({ issues, persons }) => + eq(issues.userId, persons.id) + ) + .select(({ issues, persons }) => ({ + id: issues.id, + title: issues.title, + userName: persons.name + })) +) +``` + +```ts +// Handle loading and error states +const todosQuery = useLiveQuery((q) => + q.from({ todos: todoCollection }) +) + +return ( + + +
Loading...
+
+ +
Error: {todosQuery.status}
+
+ + + {(todo) =>
  • {todo.text}
  • } +
    +
    +
    +) +``` + +```ts +// Use Suspense boundaries +const todosQuery = useLiveQuery((q) => + q.from({ todos: todoCollection }) +) + +return ( + Loading...}> + + {(todo) =>
  • {todo.text}
  • } +
    +
    +) +``` diff --git a/docs/framework/svelte/reference/functions/useLiveQuery.md b/docs/framework/svelte/reference/functions/useLiveQuery.md index 74b6534f4..1ad0b46d1 100644 --- a/docs/framework/svelte/reference/functions/useLiveQuery.md +++ b/docs/framework/svelte/reference/functions/useLiveQuery.md @@ -8,7 +8,7 @@ title: useLiveQuery ## Call Signature ```ts -function useLiveQuery(queryFn, deps?): UseLiveQueryReturn<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, InferResultType>; +function useLiveQuery(queryFn, deps?): UseLiveQueryReturn<{ [K in string | number | symbol]: ResultValue[K] }, InferResultType>; ``` Defined in: [useLiveQuery.svelte.ts:160](https://github.com/TanStack/db/blob/main/packages/svelte-db/src/useLiveQuery.svelte.ts#L160) @@ -37,7 +37,7 @@ Array of reactive dependencies that trigger query re-execution when changed ### Returns -[`UseLiveQueryReturn`](../interfaces/UseLiveQueryReturn.md)\<\{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \}, `InferResultType`\<`TContext`\>\> +[`UseLiveQueryReturn`](../interfaces/UseLiveQueryReturn.md)\<\{ \[K in string \| number \| symbol\]: ResultValue\\[K\] \}, `InferResultType`\<`TContext`\>\> Reactive object with query data, state, and status information @@ -134,7 +134,7 @@ const todosQuery = useLiveQuery((q) => ## Call Signature ```ts -function useLiveQuery(queryFn, deps?): UseLiveQueryReturn<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, InferResultType | undefined>; +function useLiveQuery(queryFn, deps?): UseLiveQueryReturn<{ [K in string | number | symbol]: ResultValue[K] }, InferResultType | undefined>; ``` Defined in: [useLiveQuery.svelte.ts:166](https://github.com/TanStack/db/blob/main/packages/svelte-db/src/useLiveQuery.svelte.ts#L166) @@ -163,7 +163,7 @@ Array of reactive dependencies that trigger query re-execution when changed ### Returns -[`UseLiveQueryReturn`](../interfaces/UseLiveQueryReturn.md)\<\{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \}, `InferResultType`\<`TContext`\> \| `undefined`\> +[`UseLiveQueryReturn`](../interfaces/UseLiveQueryReturn.md)\<\{ \[K in string \| number \| symbol\]: ResultValue\\[K\] \}, `InferResultType`\<`TContext`\> \| `undefined`\> Reactive object with query data, state, and status information @@ -260,7 +260,7 @@ const todosQuery = useLiveQuery((q) => ## Call Signature ```ts -function useLiveQuery(config, deps?): UseLiveQueryReturn<{ [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }, InferResultType>; +function useLiveQuery(config, deps?): UseLiveQueryReturn<{ [K in string | number | symbol]: ResultValue[K] }, InferResultType>; ``` Defined in: [useLiveQuery.svelte.ts:214](https://github.com/TanStack/db/blob/main/packages/svelte-db/src/useLiveQuery.svelte.ts#L214) @@ -289,7 +289,7 @@ Array of reactive dependencies that trigger query re-execution when changed ### Returns -[`UseLiveQueryReturn`](../interfaces/UseLiveQueryReturn.md)\<\{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \}, `InferResultType`\<`TContext`\>\> +[`UseLiveQueryReturn`](../interfaces/UseLiveQueryReturn.md)\<\{ \[K in string \| number \| symbol\]: ResultValue\\[K\] \}, `InferResultType`\<`TContext`\>\> Reactive object with query data, state, and status information diff --git a/docs/framework/vue/reference/interfaces/UseLiveQueryReturn.md b/docs/framework/vue/reference/interfaces/UseLiveQueryReturn.md index 90a8e7299..d434f46cd 100644 --- a/docs/framework/vue/reference/interfaces/UseLiveQueryReturn.md +++ b/docs/framework/vue/reference/interfaces/UseLiveQueryReturn.md @@ -20,8 +20,8 @@ Return type for useLiveQuery hook ### collection ```ts -collection: ComputedRef, { [K in string | number | symbol]: (TContext["result"] extends object ? any[any] : TContext["hasJoins"] extends true ? TContext["schema"] : TContext["schema"][TContext["fromSourceName"]])[K] }>>; +collection: ComputedRef[K] }, string | number, { +}, StandardSchemaV1, { [K in string | number | symbol]: ResultValue[K] }>>; ``` Defined in: [useLiveQuery.ts:43](https://github.com/TanStack/db/blob/main/packages/vue-db/src/useLiveQuery.ts#L43) @@ -105,7 +105,7 @@ True when query has received first data and is ready ### state ```ts -state: ComputedRef>; +state: ComputedRef[K] }>>; ``` Defined in: [useLiveQuery.ts:41](https://github.com/TanStack/db/blob/main/packages/vue-db/src/useLiveQuery.ts#L41) diff --git a/docs/reference/@tanstack/namespaces/IR/classes/Aggregate.md b/docs/reference/@tanstack/namespaces/IR/classes/Aggregate.md index 75915c41c..19066baac 100644 --- a/docs/reference/@tanstack/namespaces/IR/classes/Aggregate.md +++ b/docs/reference/@tanstack/namespaces/IR/classes/Aggregate.md @@ -5,7 +5,7 @@ title: Aggregate # Class: Aggregate\ -Defined in: [packages/db/src/query/ir.ts:125](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L125) +Defined in: [packages/db/src/query/ir.ts:129](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L129) ## Extends @@ -25,7 +25,7 @@ Defined in: [packages/db/src/query/ir.ts:125](https://github.com/TanStack/db/blo new Aggregate(name, args): Aggregate; ``` -Defined in: [packages/db/src/query/ir.ts:127](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L127) +Defined in: [packages/db/src/query/ir.ts:131](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L131) #### Parameters @@ -55,7 +55,7 @@ BaseExpression.constructor readonly __returnType: T; ``` -Defined in: [packages/db/src/query/ir.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L69) +Defined in: [packages/db/src/query/ir.ts:73](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L73) **`Internal`** @@ -75,7 +75,7 @@ BaseExpression.__returnType args: BasicExpression[]; ``` -Defined in: [packages/db/src/query/ir.ts:129](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L129) +Defined in: [packages/db/src/query/ir.ts:133](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L133) *** @@ -85,7 +85,7 @@ Defined in: [packages/db/src/query/ir.ts:129](https://github.com/TanStack/db/blo name: string; ``` -Defined in: [packages/db/src/query/ir.ts:128](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L128) +Defined in: [packages/db/src/query/ir.ts:132](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L132) *** @@ -95,7 +95,7 @@ Defined in: [packages/db/src/query/ir.ts:128](https://github.com/TanStack/db/blo type: "agg"; ``` -Defined in: [packages/db/src/query/ir.ts:126](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L126) +Defined in: [packages/db/src/query/ir.ts:130](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L130) #### Overrides diff --git a/docs/reference/@tanstack/namespaces/IR/classes/CollectionRef.md b/docs/reference/@tanstack/namespaces/IR/classes/CollectionRef.md index 1550a7e6f..416a1c83e 100644 --- a/docs/reference/@tanstack/namespaces/IR/classes/CollectionRef.md +++ b/docs/reference/@tanstack/namespaces/IR/classes/CollectionRef.md @@ -5,7 +5,7 @@ title: CollectionRef # Class: CollectionRef -Defined in: [packages/db/src/query/ir.ts:72](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L72) +Defined in: [packages/db/src/query/ir.ts:76](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L76) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/query/ir.ts:72](https://github.com/TanStack/db/blob new CollectionRef(collection, alias): CollectionRef; ``` -Defined in: [packages/db/src/query/ir.ts:74](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L74) +Defined in: [packages/db/src/query/ir.ts:78](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L78) #### Parameters @@ -49,7 +49,7 @@ BaseExpression.constructor readonly __returnType: any; ``` -Defined in: [packages/db/src/query/ir.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L69) +Defined in: [packages/db/src/query/ir.ts:73](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L73) **`Internal`** @@ -69,7 +69,7 @@ BaseExpression.__returnType alias: string; ``` -Defined in: [packages/db/src/query/ir.ts:76](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L76) +Defined in: [packages/db/src/query/ir.ts:80](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L80) *** @@ -79,7 +79,7 @@ Defined in: [packages/db/src/query/ir.ts:76](https://github.com/TanStack/db/blob collection: CollectionImpl; ``` -Defined in: [packages/db/src/query/ir.ts:75](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L75) +Defined in: [packages/db/src/query/ir.ts:79](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L79) *** @@ -89,7 +89,7 @@ Defined in: [packages/db/src/query/ir.ts:75](https://github.com/TanStack/db/blob type: "collectionRef"; ``` -Defined in: [packages/db/src/query/ir.ts:73](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L73) +Defined in: [packages/db/src/query/ir.ts:77](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L77) #### Overrides diff --git a/docs/reference/@tanstack/namespaces/IR/classes/Func.md b/docs/reference/@tanstack/namespaces/IR/classes/Func.md index 37fe6c377..4d6fb7984 100644 --- a/docs/reference/@tanstack/namespaces/IR/classes/Func.md +++ b/docs/reference/@tanstack/namespaces/IR/classes/Func.md @@ -5,7 +5,7 @@ title: Func # Class: Func\ -Defined in: [packages/db/src/query/ir.ts:110](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L110) +Defined in: [packages/db/src/query/ir.ts:114](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L114) ## Extends @@ -25,7 +25,7 @@ Defined in: [packages/db/src/query/ir.ts:110](https://github.com/TanStack/db/blo new Func(name, args): Func; ``` -Defined in: [packages/db/src/query/ir.ts:112](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L112) +Defined in: [packages/db/src/query/ir.ts:116](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L116) #### Parameters @@ -55,7 +55,7 @@ BaseExpression.constructor readonly __returnType: T; ``` -Defined in: [packages/db/src/query/ir.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L69) +Defined in: [packages/db/src/query/ir.ts:73](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L73) **`Internal`** @@ -75,7 +75,7 @@ BaseExpression.__returnType args: BasicExpression[]; ``` -Defined in: [packages/db/src/query/ir.ts:114](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L114) +Defined in: [packages/db/src/query/ir.ts:118](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L118) *** @@ -85,7 +85,7 @@ Defined in: [packages/db/src/query/ir.ts:114](https://github.com/TanStack/db/blo name: string; ``` -Defined in: [packages/db/src/query/ir.ts:113](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L113) +Defined in: [packages/db/src/query/ir.ts:117](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L117) *** @@ -95,7 +95,7 @@ Defined in: [packages/db/src/query/ir.ts:113](https://github.com/TanStack/db/blo type: "func"; ``` -Defined in: [packages/db/src/query/ir.ts:111](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L111) +Defined in: [packages/db/src/query/ir.ts:115](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L115) #### Overrides diff --git a/docs/reference/@tanstack/namespaces/IR/classes/IncludesSubquery.md b/docs/reference/@tanstack/namespaces/IR/classes/IncludesSubquery.md new file mode 100644 index 000000000..8d932c9ea --- /dev/null +++ b/docs/reference/@tanstack/namespaces/IR/classes/IncludesSubquery.md @@ -0,0 +1,190 @@ +--- +id: IncludesSubquery +title: IncludesSubquery +--- + +# Class: IncludesSubquery + +Defined in: [packages/db/src/query/ir.ts:139](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L139) + +## Extends + +- `BaseExpression` + +## Constructors + +### Constructor + +```ts +new IncludesSubquery( + query, + correlationField, + childCorrelationField, + fieldName, + parentFilters?, + parentProjection?, + materialization?, + scalarField?): IncludesSubquery; +``` + +Defined in: [packages/db/src/query/ir.ts:141](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L141) + +#### Parameters + +##### query + +[`QueryIR`](../interfaces/QueryIR.md) + +##### correlationField + +[`PropRef`](PropRef.md) + +##### childCorrelationField + +[`PropRef`](PropRef.md) + +##### fieldName + +`string` + +##### parentFilters? + +[`Where`](../type-aliases/Where.md)[] + +##### parentProjection? + +[`PropRef`](PropRef.md)\<`any`\>[] + +##### materialization? + +[`IncludesMaterialization`](../type-aliases/IncludesMaterialization.md) = `...` + +##### scalarField? + +`string` + +#### Returns + +`IncludesSubquery` + +#### Overrides + +```ts +BaseExpression.constructor +``` + +## Properties + +### \_\_returnType + +```ts +readonly __returnType: any; +``` + +Defined in: [packages/db/src/query/ir.ts:73](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L73) + +**`Internal`** + +- Type brand for TypeScript inference + +#### Inherited from + +```ts +BaseExpression.__returnType +``` + +*** + +### childCorrelationField + +```ts +childCorrelationField: PropRef; +``` + +Defined in: [packages/db/src/query/ir.ts:144](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L144) + +*** + +### correlationField + +```ts +correlationField: PropRef; +``` + +Defined in: [packages/db/src/query/ir.ts:143](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L143) + +*** + +### fieldName + +```ts +fieldName: string; +``` + +Defined in: [packages/db/src/query/ir.ts:145](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L145) + +*** + +### materialization + +```ts +materialization: IncludesMaterialization; +``` + +Defined in: [packages/db/src/query/ir.ts:148](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L148) + +*** + +### parentFilters? + +```ts +optional parentFilters: Where[]; +``` + +Defined in: [packages/db/src/query/ir.ts:146](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L146) + +*** + +### parentProjection? + +```ts +optional parentProjection: PropRef[]; +``` + +Defined in: [packages/db/src/query/ir.ts:147](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L147) + +*** + +### query + +```ts +query: QueryIR; +``` + +Defined in: [packages/db/src/query/ir.ts:142](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L142) + +*** + +### scalarField? + +```ts +optional scalarField: string; +``` + +Defined in: [packages/db/src/query/ir.ts:149](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L149) + +*** + +### type + +```ts +type: "includesSubquery"; +``` + +Defined in: [packages/db/src/query/ir.ts:140](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L140) + +#### Overrides + +```ts +BaseExpression.type +``` diff --git a/docs/reference/@tanstack/namespaces/IR/classes/PropRef.md b/docs/reference/@tanstack/namespaces/IR/classes/PropRef.md index ac7bfd418..f9dd66cf1 100644 --- a/docs/reference/@tanstack/namespaces/IR/classes/PropRef.md +++ b/docs/reference/@tanstack/namespaces/IR/classes/PropRef.md @@ -5,7 +5,7 @@ title: PropRef # Class: PropRef\ -Defined in: [packages/db/src/query/ir.ts:92](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L92) +Defined in: [packages/db/src/query/ir.ts:96](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L96) ## Extends @@ -25,7 +25,7 @@ Defined in: [packages/db/src/query/ir.ts:92](https://github.com/TanStack/db/blob new PropRef(path): PropRef; ``` -Defined in: [packages/db/src/query/ir.ts:94](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L94) +Defined in: [packages/db/src/query/ir.ts:98](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L98) #### Parameters @@ -51,7 +51,7 @@ BaseExpression.constructor readonly __returnType: T; ``` -Defined in: [packages/db/src/query/ir.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L69) +Defined in: [packages/db/src/query/ir.ts:73](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L73) **`Internal`** @@ -71,7 +71,7 @@ BaseExpression.__returnType path: string[]; ``` -Defined in: [packages/db/src/query/ir.ts:95](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L95) +Defined in: [packages/db/src/query/ir.ts:99](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L99) *** @@ -81,7 +81,7 @@ Defined in: [packages/db/src/query/ir.ts:95](https://github.com/TanStack/db/blob type: "ref"; ``` -Defined in: [packages/db/src/query/ir.ts:93](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L93) +Defined in: [packages/db/src/query/ir.ts:97](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L97) #### Overrides diff --git a/docs/reference/@tanstack/namespaces/IR/classes/QueryRef.md b/docs/reference/@tanstack/namespaces/IR/classes/QueryRef.md index 5f29109ba..1dbc0357e 100644 --- a/docs/reference/@tanstack/namespaces/IR/classes/QueryRef.md +++ b/docs/reference/@tanstack/namespaces/IR/classes/QueryRef.md @@ -5,7 +5,7 @@ title: QueryRef # Class: QueryRef -Defined in: [packages/db/src/query/ir.ts:82](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L82) +Defined in: [packages/db/src/query/ir.ts:86](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L86) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/query/ir.ts:82](https://github.com/TanStack/db/blob new QueryRef(query, alias): QueryRef; ``` -Defined in: [packages/db/src/query/ir.ts:84](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L84) +Defined in: [packages/db/src/query/ir.ts:88](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L88) #### Parameters @@ -49,7 +49,7 @@ BaseExpression.constructor readonly __returnType: any; ``` -Defined in: [packages/db/src/query/ir.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L69) +Defined in: [packages/db/src/query/ir.ts:73](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L73) **`Internal`** @@ -69,7 +69,7 @@ BaseExpression.__returnType alias: string; ``` -Defined in: [packages/db/src/query/ir.ts:86](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L86) +Defined in: [packages/db/src/query/ir.ts:90](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L90) *** @@ -79,7 +79,7 @@ Defined in: [packages/db/src/query/ir.ts:86](https://github.com/TanStack/db/blob query: QueryIR; ``` -Defined in: [packages/db/src/query/ir.ts:85](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L85) +Defined in: [packages/db/src/query/ir.ts:89](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L89) *** @@ -89,7 +89,7 @@ Defined in: [packages/db/src/query/ir.ts:85](https://github.com/TanStack/db/blob type: "queryRef"; ``` -Defined in: [packages/db/src/query/ir.ts:83](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L83) +Defined in: [packages/db/src/query/ir.ts:87](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L87) #### Overrides diff --git a/docs/reference/@tanstack/namespaces/IR/classes/Value.md b/docs/reference/@tanstack/namespaces/IR/classes/Value.md index 448308304..fd1970ef7 100644 --- a/docs/reference/@tanstack/namespaces/IR/classes/Value.md +++ b/docs/reference/@tanstack/namespaces/IR/classes/Value.md @@ -5,7 +5,7 @@ title: Value # Class: Value\ -Defined in: [packages/db/src/query/ir.ts:101](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L101) +Defined in: [packages/db/src/query/ir.ts:105](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L105) ## Extends @@ -25,7 +25,7 @@ Defined in: [packages/db/src/query/ir.ts:101](https://github.com/TanStack/db/blo new Value(value): Value; ``` -Defined in: [packages/db/src/query/ir.ts:103](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L103) +Defined in: [packages/db/src/query/ir.ts:107](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L107) #### Parameters @@ -51,7 +51,7 @@ BaseExpression.constructor readonly __returnType: T; ``` -Defined in: [packages/db/src/query/ir.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L69) +Defined in: [packages/db/src/query/ir.ts:73](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L73) **`Internal`** @@ -71,7 +71,7 @@ BaseExpression.__returnType type: "val"; ``` -Defined in: [packages/db/src/query/ir.ts:102](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L102) +Defined in: [packages/db/src/query/ir.ts:106](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L106) #### Overrides @@ -87,4 +87,4 @@ BaseExpression.type value: T; ``` -Defined in: [packages/db/src/query/ir.ts:104](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L104) +Defined in: [packages/db/src/query/ir.ts:108](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L108) diff --git a/docs/reference/@tanstack/namespaces/IR/functions/createResidualWhere.md b/docs/reference/@tanstack/namespaces/IR/functions/createResidualWhere.md index 93851c21c..e4c71d86f 100644 --- a/docs/reference/@tanstack/namespaces/IR/functions/createResidualWhere.md +++ b/docs/reference/@tanstack/namespaces/IR/functions/createResidualWhere.md @@ -9,7 +9,7 @@ title: createResidualWhere function createResidualWhere(expression): Where; ``` -Defined in: [packages/db/src/query/ir.ts:187](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L187) +Defined in: [packages/db/src/query/ir.ts:208](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L208) Create a residual Where clause from an expression diff --git a/docs/reference/@tanstack/namespaces/IR/functions/followRef.md b/docs/reference/@tanstack/namespaces/IR/functions/followRef.md index 3147d38c1..5d2636f8c 100644 --- a/docs/reference/@tanstack/namespaces/IR/functions/followRef.md +++ b/docs/reference/@tanstack/namespaces/IR/functions/followRef.md @@ -17,7 +17,7 @@ function followRef( }; ``` -Defined in: [packages/db/src/query/ir.ts:213](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L213) +Defined in: [packages/db/src/query/ir.ts:234](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L234) Follows the given reference in a query until its finds the root field the reference points to. diff --git a/docs/reference/@tanstack/namespaces/IR/functions/getHavingExpression.md b/docs/reference/@tanstack/namespaces/IR/functions/getHavingExpression.md index a58eb0b7d..1ce31a66a 100644 --- a/docs/reference/@tanstack/namespaces/IR/functions/getHavingExpression.md +++ b/docs/reference/@tanstack/namespaces/IR/functions/getHavingExpression.md @@ -11,7 +11,7 @@ function getHavingExpression(having): | Aggregate; ``` -Defined in: [packages/db/src/query/ir.ts:165](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L165) +Defined in: [packages/db/src/query/ir.ts:186](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L186) Extract the expression from a HAVING clause HAVING clauses can contain aggregates, unlike regular WHERE clauses diff --git a/docs/reference/@tanstack/namespaces/IR/functions/getWhereExpression.md b/docs/reference/@tanstack/namespaces/IR/functions/getWhereExpression.md index 41bb467a8..fbf8d4994 100644 --- a/docs/reference/@tanstack/namespaces/IR/functions/getWhereExpression.md +++ b/docs/reference/@tanstack/namespaces/IR/functions/getWhereExpression.md @@ -9,7 +9,7 @@ title: getWhereExpression function getWhereExpression(where): BasicExpression; ``` -Defined in: [packages/db/src/query/ir.ts:155](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L155) +Defined in: [packages/db/src/query/ir.ts:176](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L176) Extract the expression from a Where clause diff --git a/docs/reference/@tanstack/namespaces/IR/functions/isExpressionLike.md b/docs/reference/@tanstack/namespaces/IR/functions/isExpressionLike.md index a9e580e1a..07961d0d1 100644 --- a/docs/reference/@tanstack/namespaces/IR/functions/isExpressionLike.md +++ b/docs/reference/@tanstack/namespaces/IR/functions/isExpressionLike.md @@ -9,7 +9,7 @@ title: isExpressionLike function isExpressionLike(value): boolean; ``` -Defined in: [packages/db/src/query/ir.ts:139](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L139) +Defined in: [packages/db/src/query/ir.ts:159](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L159) Runtime helper to detect IR expression-like objects. Prefer this over ad-hoc local implementations to keep behavior consistent. diff --git a/docs/reference/@tanstack/namespaces/IR/functions/isResidualWhere.md b/docs/reference/@tanstack/namespaces/IR/functions/isResidualWhere.md index 28f2a059c..ff3b6b22f 100644 --- a/docs/reference/@tanstack/namespaces/IR/functions/isResidualWhere.md +++ b/docs/reference/@tanstack/namespaces/IR/functions/isResidualWhere.md @@ -9,7 +9,7 @@ title: isResidualWhere function isResidualWhere(where): boolean; ``` -Defined in: [packages/db/src/query/ir.ts:176](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L176) +Defined in: [packages/db/src/query/ir.ts:197](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L197) Check if a Where clause is marked as residual diff --git a/docs/reference/@tanstack/namespaces/IR/index.md b/docs/reference/@tanstack/namespaces/IR/index.md index 2e6b180ed..415a36554 100644 --- a/docs/reference/@tanstack/namespaces/IR/index.md +++ b/docs/reference/@tanstack/namespaces/IR/index.md @@ -10,6 +10,7 @@ title: IR - [Aggregate](classes/Aggregate.md) - [CollectionRef](classes/CollectionRef.md) - [Func](classes/Func.md) +- [IncludesSubquery](classes/IncludesSubquery.md) - [PropRef](classes/PropRef.md) - [QueryRef](classes/QueryRef.md) - [Value](classes/Value.md) @@ -25,6 +26,7 @@ title: IR - [From](type-aliases/From.md) - [GroupBy](type-aliases/GroupBy.md) - [Having](type-aliases/Having.md) +- [IncludesMaterialization](type-aliases/IncludesMaterialization.md) - [Join](type-aliases/Join.md) - [Limit](type-aliases/Limit.md) - [Offset](type-aliases/Offset.md) @@ -34,6 +36,10 @@ title: IR - [Select](type-aliases/Select.md) - [Where](type-aliases/Where.md) +## Variables + +- [INCLUDES\_SCALAR\_FIELD](variables/INCLUDES_SCALAR_FIELD.md) + ## Functions - [createResidualWhere](functions/createResidualWhere.md) diff --git a/docs/reference/@tanstack/namespaces/IR/interfaces/JoinClause.md b/docs/reference/@tanstack/namespaces/IR/interfaces/JoinClause.md index 0ba211c77..e41a4e715 100644 --- a/docs/reference/@tanstack/namespaces/IR/interfaces/JoinClause.md +++ b/docs/reference/@tanstack/namespaces/IR/interfaces/JoinClause.md @@ -5,7 +5,7 @@ title: JoinClause # Interface: JoinClause -Defined in: [packages/db/src/query/ir.ts:36](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L36) +Defined in: [packages/db/src/query/ir.ts:40](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L40) ## Properties @@ -17,7 +17,7 @@ from: | QueryRef; ``` -Defined in: [packages/db/src/query/ir.ts:37](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L37) +Defined in: [packages/db/src/query/ir.ts:41](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L41) *** @@ -27,7 +27,7 @@ Defined in: [packages/db/src/query/ir.ts:37](https://github.com/TanStack/db/blob left: BasicExpression; ``` -Defined in: [packages/db/src/query/ir.ts:39](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L39) +Defined in: [packages/db/src/query/ir.ts:43](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L43) *** @@ -37,7 +37,7 @@ Defined in: [packages/db/src/query/ir.ts:39](https://github.com/TanStack/db/blob right: BasicExpression; ``` -Defined in: [packages/db/src/query/ir.ts:40](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L40) +Defined in: [packages/db/src/query/ir.ts:44](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L44) *** @@ -47,4 +47,4 @@ Defined in: [packages/db/src/query/ir.ts:40](https://github.com/TanStack/db/blob type: "inner" | "left" | "right" | "full" | "outer" | "cross"; ``` -Defined in: [packages/db/src/query/ir.ts:38](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L38) +Defined in: [packages/db/src/query/ir.ts:42](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L42) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/BasicExpression.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/BasicExpression.md index 8621d0743..de4676e5b 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/BasicExpression.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/BasicExpression.md @@ -12,7 +12,7 @@ type BasicExpression = | Func; ``` -Defined in: [packages/db/src/query/ir.ts:123](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L123) +Defined in: [packages/db/src/query/ir.ts:127](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L127) ## Type Parameters diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/From.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/From.md index 53396c221..f5dc25e14 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/From.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/From.md @@ -11,4 +11,4 @@ type From = | QueryRef; ``` -Defined in: [packages/db/src/query/ir.ts:28](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L28) +Defined in: [packages/db/src/query/ir.ts:32](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L32) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/GroupBy.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/GroupBy.md index 71426706e..1ecd39996 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/GroupBy.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/GroupBy.md @@ -9,4 +9,4 @@ title: GroupBy type GroupBy = BasicExpression[]; ``` -Defined in: [packages/db/src/query/ir.ts:47](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L47) +Defined in: [packages/db/src/query/ir.ts:51](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L51) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/Having.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/Having.md index 7c101b514..7654798e3 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/Having.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/Having.md @@ -9,4 +9,4 @@ title: Having type Having = Where; ``` -Defined in: [packages/db/src/query/ir.ts:49](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L49) +Defined in: [packages/db/src/query/ir.ts:53](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L53) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/IncludesMaterialization.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/IncludesMaterialization.md new file mode 100644 index 000000000..02afe1663 --- /dev/null +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/IncludesMaterialization.md @@ -0,0 +1,12 @@ +--- +id: IncludesMaterialization +title: IncludesMaterialization +--- + +# Type Alias: IncludesMaterialization + +```ts +type IncludesMaterialization = "collection" | "array" | "concat"; +``` + +Defined in: [packages/db/src/query/ir.ts:28](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L28) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/Join.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/Join.md index f05df96fd..53b84b8b4 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/Join.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/Join.md @@ -9,4 +9,4 @@ title: Join type Join = JoinClause[]; ``` -Defined in: [packages/db/src/query/ir.ts:34](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L34) +Defined in: [packages/db/src/query/ir.ts:38](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L38) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/Limit.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/Limit.md index fd93855d3..38be20e01 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/Limit.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/Limit.md @@ -9,4 +9,4 @@ title: Limit type Limit = number; ``` -Defined in: [packages/db/src/query/ir.ts:60](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L60) +Defined in: [packages/db/src/query/ir.ts:64](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L64) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/Offset.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/Offset.md index eeb67a560..771c53d41 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/Offset.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/Offset.md @@ -9,4 +9,4 @@ title: Offset type Offset = number; ``` -Defined in: [packages/db/src/query/ir.ts:62](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L62) +Defined in: [packages/db/src/query/ir.ts:66](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L66) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderBy.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderBy.md index af3fac551..2d5a450cd 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderBy.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderBy.md @@ -9,4 +9,4 @@ title: OrderBy type OrderBy = OrderByClause[]; ``` -Defined in: [packages/db/src/query/ir.ts:51](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L51) +Defined in: [packages/db/src/query/ir.ts:55](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L55) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderByClause.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderByClause.md index 98ea1969e..2770aed38 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderByClause.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderByClause.md @@ -9,7 +9,7 @@ title: OrderByClause type OrderByClause = object; ``` -Defined in: [packages/db/src/query/ir.ts:53](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L53) +Defined in: [packages/db/src/query/ir.ts:57](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L57) ## Properties @@ -19,7 +19,7 @@ Defined in: [packages/db/src/query/ir.ts:53](https://github.com/TanStack/db/blob compareOptions: CompareOptions; ``` -Defined in: [packages/db/src/query/ir.ts:55](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L55) +Defined in: [packages/db/src/query/ir.ts:59](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L59) *** @@ -29,4 +29,4 @@ Defined in: [packages/db/src/query/ir.ts:55](https://github.com/TanStack/db/blob expression: BasicExpression; ``` -Defined in: [packages/db/src/query/ir.ts:54](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L54) +Defined in: [packages/db/src/query/ir.ts:58](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L58) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderByDirection.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderByDirection.md index 043ef946d..58c632a10 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderByDirection.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/OrderByDirection.md @@ -9,4 +9,4 @@ title: OrderByDirection type OrderByDirection = "asc" | "desc"; ``` -Defined in: [packages/db/src/query/ir.ts:58](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L58) +Defined in: [packages/db/src/query/ir.ts:62](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L62) diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/Select.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/Select.md index e6a4d7e38..4016ef6f4 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/Select.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/Select.md @@ -9,13 +9,14 @@ title: Select type Select = object; ``` -Defined in: [packages/db/src/query/ir.ts:30](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L30) +Defined in: [packages/db/src/query/ir.ts:34](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L34) ## Index Signature ```ts [alias: string]: | BasicExpression - | Aggregate | Select + | Aggregate + | IncludesSubquery ``` diff --git a/docs/reference/@tanstack/namespaces/IR/type-aliases/Where.md b/docs/reference/@tanstack/namespaces/IR/type-aliases/Where.md index ac22debbd..fdbb87887 100644 --- a/docs/reference/@tanstack/namespaces/IR/type-aliases/Where.md +++ b/docs/reference/@tanstack/namespaces/IR/type-aliases/Where.md @@ -14,4 +14,4 @@ type Where = }; ``` -Defined in: [packages/db/src/query/ir.ts:43](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L43) +Defined in: [packages/db/src/query/ir.ts:47](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L47) diff --git a/docs/reference/@tanstack/namespaces/IR/variables/INCLUDES_SCALAR_FIELD.md b/docs/reference/@tanstack/namespaces/IR/variables/INCLUDES_SCALAR_FIELD.md new file mode 100644 index 000000000..c68802f24 --- /dev/null +++ b/docs/reference/@tanstack/namespaces/IR/variables/INCLUDES_SCALAR_FIELD.md @@ -0,0 +1,12 @@ +--- +id: INCLUDES_SCALAR_FIELD +title: INCLUDES_SCALAR_FIELD +--- + +# Variable: INCLUDES\_SCALAR\_FIELD + +```ts +const INCLUDES_SCALAR_FIELD: "__includes_scalar__"; +``` + +Defined in: [packages/db/src/query/ir.ts:30](https://github.com/TanStack/db/blob/main/packages/db/src/query/ir.ts#L30) diff --git a/docs/reference/classes/AggregateFunctionNotInSelectError.md b/docs/reference/classes/AggregateFunctionNotInSelectError.md index 79e85c6a8..19e08fb68 100644 --- a/docs/reference/classes/AggregateFunctionNotInSelectError.md +++ b/docs/reference/classes/AggregateFunctionNotInSelectError.md @@ -5,7 +5,7 @@ title: AggregateFunctionNotInSelectError # Class: AggregateFunctionNotInSelectError -Defined in: [packages/db/src/errors.ts:605](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L605) +Defined in: [packages/db/src/errors.ts:614](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L614) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:605](https://github.com/TanStack/db/blob/ new AggregateFunctionNotInSelectError(functionName): AggregateFunctionNotInSelectError; ``` -Defined in: [packages/db/src/errors.ts:606](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L606) +Defined in: [packages/db/src/errors.ts:615](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L615) #### Parameters diff --git a/docs/reference/classes/AggregateNotSupportedError.md b/docs/reference/classes/AggregateNotSupportedError.md index 2dbb09b2b..7cdcf25e5 100644 --- a/docs/reference/classes/AggregateNotSupportedError.md +++ b/docs/reference/classes/AggregateNotSupportedError.md @@ -5,7 +5,7 @@ title: AggregateNotSupportedError # Class: AggregateNotSupportedError -Defined in: [packages/db/src/errors.ts:721](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L721) +Defined in: [packages/db/src/errors.ts:730](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L730) Error thrown when aggregate expressions are used outside of a GROUP BY context. @@ -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:722](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L722) +Defined in: [packages/db/src/errors.ts:731](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L731) #### Returns diff --git a/docs/reference/classes/BTreeIndex.md b/docs/reference/classes/BTreeIndex.md index b803797a7..3072cef86 100644 --- a/docs/reference/classes/BTreeIndex.md +++ b/docs/reference/classes/BTreeIndex.md @@ -18,7 +18,7 @@ This maintains items in sorted order and provides efficient range operations ### TKey -`TKey` *extends* `string` \| `number` \| `undefined` = `string` \| `number` \| `undefined` +`TKey` *extends* `string` \| `number` = `string` \| `number` ## Constructors @@ -384,7 +384,7 @@ Performs an equality lookup protected evaluateIndexExpression(item): any; ``` -Defined in: [packages/db/src/indexes/base-index.ts:195](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L195) +Defined in: [packages/db/src/indexes/base-index.ts:194](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L194) #### Parameters @@ -458,7 +458,7 @@ Defined in: [packages/db/src/indexes/btree-index.ts:78](https://github.com/TanSt ##### \_options? -[`BTreeIndexOptions`](../interfaces/BTreeIndexOptions.md) +`BTreeIndexOptions` #### Returns @@ -592,7 +592,7 @@ This is more efficient for compound queries like "WHERE a > 5 AND a < 10" ##### options -[`RangeQueryOptions`](../interfaces/RangeQueryOptions.md) = `{}` +[`BTreeRangeQueryOptions`](../interfaces/BTreeRangeQueryOptions.md) = `{}` #### Returns @@ -618,7 +618,7 @@ Performs a reversed range query ##### options -[`RangeQueryOptions`](../interfaces/RangeQueryOptions.md) = `{}` +[`BTreeRangeQueryOptions`](../interfaces/BTreeRangeQueryOptions.md) = `{}` #### Returns @@ -848,7 +848,7 @@ The last n items protected trackLookup(startTime): void; ``` -Defined in: [packages/db/src/indexes/base-index.ts:200](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L200) +Defined in: [packages/db/src/indexes/base-index.ts:199](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L199) #### Parameters @@ -909,7 +909,7 @@ Updates a value in the index protected updateTimestamp(): void; ``` -Defined in: [packages/db/src/indexes/base-index.ts:206](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L206) +Defined in: [packages/db/src/indexes/base-index.ts:205](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L205) #### Returns diff --git a/docs/reference/classes/BaseIndex.md b/docs/reference/classes/BaseIndex.md index 1a46c7494..bd512fdbe 100644 --- a/docs/reference/classes/BaseIndex.md +++ b/docs/reference/classes/BaseIndex.md @@ -11,13 +11,14 @@ Base abstract class that all index types extend ## Extended by +- [`BasicIndex`](BasicIndex.md) - [`BTreeIndex`](BTreeIndex.md) ## Type Parameters ### TKey -`TKey` *extends* `string` \| `number` \| `undefined` = `string` \| `number` \| `undefined` +`TKey` *extends* `string` \| `number` = `string` \| `number` ## Implements @@ -341,7 +342,7 @@ Defined in: [packages/db/src/indexes/base-index.ts:133](https://github.com/TanSt protected evaluateIndexExpression(item): any; ``` -Defined in: [packages/db/src/indexes/base-index.ts:195](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L195) +Defined in: [packages/db/src/indexes/base-index.ts:194](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L194) #### Parameters @@ -403,7 +404,7 @@ Defined in: [packages/db/src/indexes/base-index.ts:134](https://github.com/TanSt abstract protected initialize(options?): void; ``` -Defined in: [packages/db/src/indexes/base-index.ts:193](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L193) +Defined in: [packages/db/src/indexes/base-index.ts:192](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L192) #### Parameters @@ -534,7 +535,7 @@ Defined in: [packages/db/src/indexes/base-index.ts:135](https://github.com/TanSt ##### options -[`RangeQueryOptions`](../interfaces/RangeQueryOptions.md) +[`BTreeRangeQueryOptions`](../interfaces/BTreeRangeQueryOptions.md) #### Returns @@ -558,7 +559,7 @@ Defined in: [packages/db/src/indexes/base-index.ts:136](https://github.com/TanSt ##### options -[`RangeQueryOptions`](../interfaces/RangeQueryOptions.md) +[`BTreeRangeQueryOptions`](../interfaces/BTreeRangeQueryOptions.md) #### Returns @@ -754,7 +755,7 @@ Defined in: [packages/db/src/indexes/base-index.ts:128](https://github.com/TanSt protected trackLookup(startTime): void; ``` -Defined in: [packages/db/src/indexes/base-index.ts:200](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L200) +Defined in: [packages/db/src/indexes/base-index.ts:199](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L199) #### Parameters @@ -809,7 +810,7 @@ Defined in: [packages/db/src/indexes/base-index.ts:110](https://github.com/TanSt protected updateTimestamp(): void; ``` -Defined in: [packages/db/src/indexes/base-index.ts:206](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L206) +Defined in: [packages/db/src/indexes/base-index.ts:205](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L205) #### Returns diff --git a/docs/reference/classes/BaseQueryBuilder.md b/docs/reference/classes/BaseQueryBuilder.md index 8cc8a5476..224e68885 100644 --- a/docs/reference/classes/BaseQueryBuilder.md +++ b/docs/reference/classes/BaseQueryBuilder.md @@ -5,7 +5,7 @@ title: BaseQueryBuilder # Class: BaseQueryBuilder\ -Defined in: [packages/db/src/query/builder/index.ts:55](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L55) +Defined in: [packages/db/src/query/builder/index.ts:63](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L63) ## Type Parameters @@ -21,7 +21,7 @@ Defined in: [packages/db/src/query/builder/index.ts:55](https://github.com/TanSt new BaseQueryBuilder(query): BaseQueryBuilder; ``` -Defined in: [packages/db/src/query/builder/index.ts:58](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L58) +Defined in: [packages/db/src/query/builder/index.ts:66](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L66) #### Parameters @@ -43,7 +43,7 @@ Defined in: [packages/db/src/query/builder/index.ts:58](https://github.com/TanSt get fn(): object; ``` -Defined in: [packages/db/src/query/builder/index.ts:744](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L744) +Defined in: [packages/db/src/query/builder/index.ts:770](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L770) Functional variants of the query builder These are imperative function that are called for ery row. @@ -176,7 +176,7 @@ query _getQuery(): QueryIR; ``` -Defined in: [packages/db/src/query/builder/index.ts:831](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L831) +Defined in: [packages/db/src/query/builder/index.ts:857](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L857) #### Returns @@ -190,7 +190,7 @@ Defined in: [packages/db/src/query/builder/index.ts:831](https://github.com/TanS distinct(): QueryBuilder; ``` -Defined in: [packages/db/src/query/builder/index.ts:683](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L683) +Defined in: [packages/db/src/query/builder/index.ts:709](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L709) Specify that the query should return distinct rows. Deduplicates rows based on the selected columns. @@ -207,7 +207,7 @@ A QueryBuilder with distinct enabled // Get countries our users are from query .from({ users: usersCollection }) - .select(({users}) => users.country) + .select(({users}) => ({ country: users.country })) .distinct() ``` @@ -219,7 +219,7 @@ query findOne(): QueryBuilder; ``` -Defined in: [packages/db/src/query/builder/index.ts:703](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L703) +Defined in: [packages/db/src/query/builder/index.ts:729](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L729) Specify that the query should return a single result @@ -252,7 +252,7 @@ from(source): QueryBuilder<{ }>; ``` -Defined in: [packages/db/src/query/builder/index.ts:137](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L137) +Defined in: [packages/db/src/query/builder/index.ts:145](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L145) Specify the source table or subquery for the query @@ -300,7 +300,7 @@ query.from({ activeUsers }) fullJoin(source, onCallback): QueryBuilder, "full">>; ``` -Defined in: [packages/db/src/query/builder/index.ts:328](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L328) +Defined in: [packages/db/src/query/builder/index.ts:336](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L336) Perform a FULL JOIN with another table or subquery @@ -320,7 +320,7 @@ An object with a single key-value pair where the key is the table alias and the ##### onCallback -[`JoinOnCallback`](../type-aliases/JoinOnCallback.md)\<[`MergeContextForJoinCallback`](../type-aliases/MergeContextForJoinCallback.md)\<`TContext`, \{ \[K in string \| number \| symbol\]: \{ \[K in string \| number \| symbol\]: TSource\[K\] extends CollectionImpl\ ? InferCollectionType\ : TSource\[K\] extends QueryBuilder\ ? \{ \[K in string \| number \| symbol\]: ((...)\[(...)\] extends object ? any\[any\] : (...) extends (...) ? (...) : (...))\[K\] \} : never \}\[K\] \}\>\> +[`JoinOnCallback`](../type-aliases/JoinOnCallback.md)\<[`MergeContextForJoinCallback`](../type-aliases/MergeContextForJoinCallback.md)\<`TContext`, \{ \[K in string \| number \| symbol\]: \{ \[K in string \| number \| symbol\]: TSource\[K\] extends CollectionImpl\ ? InferCollectionType\ : TSource\[K\] extends QueryBuilder\ ? \{ \[K in string \| number \| symbol\]: ResultValue\\[K\] \} : never \}\[K\] \}\>\> A function that receives table references and returns the join condition @@ -347,7 +347,7 @@ query groupBy(callback): QueryBuilder; ``` -Defined in: [packages/db/src/query/builder/index.ts:605](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L605) +Defined in: [packages/db/src/query/builder/index.ts:631](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L631) Group rows by one or more columns for aggregation @@ -396,7 +396,7 @@ query having(callback): QueryBuilder; ``` -Defined in: [packages/db/src/query/builder/index.ts:422](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L422) +Defined in: [packages/db/src/query/builder/index.ts:430](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L430) Filter grouped rows based on aggregate conditions @@ -445,7 +445,7 @@ query innerJoin(source, onCallback): QueryBuilder, "inner">>; ``` -Defined in: [packages/db/src/query/builder/index.ts:302](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L302) +Defined in: [packages/db/src/query/builder/index.ts:310](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L310) Perform an INNER JOIN with another table or subquery @@ -465,7 +465,7 @@ An object with a single key-value pair where the key is the table alias and the ##### onCallback -[`JoinOnCallback`](../type-aliases/JoinOnCallback.md)\<[`MergeContextForJoinCallback`](../type-aliases/MergeContextForJoinCallback.md)\<`TContext`, \{ \[K in string \| number \| symbol\]: \{ \[K in string \| number \| symbol\]: TSource\[K\] extends CollectionImpl\ ? InferCollectionType\ : TSource\[K\] extends QueryBuilder\ ? \{ \[K in string \| number \| symbol\]: ((...)\[(...)\] extends object ? any\[any\] : (...) extends (...) ? (...) : (...))\[K\] \} : never \}\[K\] \}\>\> +[`JoinOnCallback`](../type-aliases/JoinOnCallback.md)\<[`MergeContextForJoinCallback`](../type-aliases/MergeContextForJoinCallback.md)\<`TContext`, \{ \[K in string \| number \| symbol\]: \{ \[K in string \| number \| symbol\]: TSource\[K\] extends CollectionImpl\ ? InferCollectionType\ : TSource\[K\] extends QueryBuilder\ ? \{ \[K in string \| number \| symbol\]: ResultValue\\[K\] \} : never \}\[K\] \}\>\> A function that receives table references and returns the join condition @@ -495,7 +495,7 @@ join( type): QueryBuilder, TJoinType>>; ``` -Defined in: [packages/db/src/query/builder/index.ts:180](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L180) +Defined in: [packages/db/src/query/builder/index.ts:188](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L188) Join another table or subquery to the current query @@ -519,7 +519,7 @@ An object with a single key-value pair where the key is the table alias and the ##### onCallback -[`JoinOnCallback`](../type-aliases/JoinOnCallback.md)\<[`MergeContextForJoinCallback`](../type-aliases/MergeContextForJoinCallback.md)\<`TContext`, \{ \[K in string \| number \| symbol\]: \{ \[K in string \| number \| symbol\]: TSource\[K\] extends CollectionImpl\ ? InferCollectionType\ : TSource\[K\] extends QueryBuilder\ ? \{ \[K in string \| number \| symbol\]: ((...)\[(...)\] extends object ? any\[any\] : (...) extends (...) ? (...) : (...))\[K\] \} : never \}\[K\] \}\>\> +[`JoinOnCallback`](../type-aliases/JoinOnCallback.md)\<[`MergeContextForJoinCallback`](../type-aliases/MergeContextForJoinCallback.md)\<`TContext`, \{ \[K in string \| number \| symbol\]: \{ \[K in string \| number \| symbol\]: TSource\[K\] extends CollectionImpl\ ? InferCollectionType\ : TSource\[K\] extends QueryBuilder\ ? \{ \[K in string \| number \| symbol\]: ResultValue\\[K\] \} : never \}\[K\] \}\>\> A function that receives table references and returns the join condition @@ -563,7 +563,7 @@ query leftJoin(source, onCallback): QueryBuilder, "left">>; ``` -Defined in: [packages/db/src/query/builder/index.ts:250](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L250) +Defined in: [packages/db/src/query/builder/index.ts:258](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L258) Perform a LEFT JOIN with another table or subquery @@ -583,7 +583,7 @@ An object with a single key-value pair where the key is the table alias and the ##### onCallback -[`JoinOnCallback`](../type-aliases/JoinOnCallback.md)\<[`MergeContextForJoinCallback`](../type-aliases/MergeContextForJoinCallback.md)\<`TContext`, \{ \[K in string \| number \| symbol\]: \{ \[K in string \| number \| symbol\]: TSource\[K\] extends CollectionImpl\ ? InferCollectionType\ : TSource\[K\] extends QueryBuilder\ ? \{ \[K in string \| number \| symbol\]: ((...)\[(...)\] extends object ? any\[any\] : (...) extends (...) ? (...) : (...))\[K\] \} : never \}\[K\] \}\>\> +[`JoinOnCallback`](../type-aliases/JoinOnCallback.md)\<[`MergeContextForJoinCallback`](../type-aliases/MergeContextForJoinCallback.md)\<`TContext`, \{ \[K in string \| number \| symbol\]: \{ \[K in string \| number \| symbol\]: TSource\[K\] extends CollectionImpl\ ? InferCollectionType\ : TSource\[K\] extends QueryBuilder\ ? \{ \[K in string \| number \| symbol\]: ResultValue\\[K\] \} : never \}\[K\] \}\>\> A function that receives table references and returns the join condition @@ -610,7 +610,7 @@ query limit(count): QueryBuilder; ``` -Defined in: [packages/db/src/query/builder/index.ts:638](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L638) +Defined in: [packages/db/src/query/builder/index.ts:664](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L664) Limit the number of rows returned by the query `orderBy` is required for `limit` @@ -647,7 +647,7 @@ query offset(count): QueryBuilder; ``` -Defined in: [packages/db/src/query/builder/index.ts:662](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L662) +Defined in: [packages/db/src/query/builder/index.ts:688](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L688) Skip a number of rows before returning results `orderBy` is required for `offset` @@ -685,7 +685,7 @@ query orderBy(callback, options): QueryBuilder; ``` -Defined in: [packages/db/src/query/builder/index.ts:529](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L529) +Defined in: [packages/db/src/query/builder/index.ts:555](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L555) Sort the query results by one or more columns @@ -735,7 +735,7 @@ query rightJoin(source, onCallback): QueryBuilder, "right">>; ``` -Defined in: [packages/db/src/query/builder/index.ts:276](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L276) +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) Perform a RIGHT JOIN with another table or subquery @@ -755,7 +755,7 @@ An object with a single key-value pair where the key is the table alias and the ##### onCallback -[`JoinOnCallback`](../type-aliases/JoinOnCallback.md)\<[`MergeContextForJoinCallback`](../type-aliases/MergeContextForJoinCallback.md)\<`TContext`, \{ \[K in string \| number \| symbol\]: \{ \[K in string \| number \| symbol\]: TSource\[K\] extends CollectionImpl\ ? InferCollectionType\ : TSource\[K\] extends QueryBuilder\ ? \{ \[K in string \| number \| symbol\]: ((...)\[(...)\] extends object ? any\[any\] : (...) extends (...) ? (...) : (...))\[K\] \} : never \}\[K\] \}\>\> +[`JoinOnCallback`](../type-aliases/JoinOnCallback.md)\<[`MergeContextForJoinCallback`](../type-aliases/MergeContextForJoinCallback.md)\<`TContext`, \{ \[K in string \| number \| symbol\]: \{ \[K in string \| number \| symbol\]: TSource\[K\] extends CollectionImpl\ ? InferCollectionType\ : TSource\[K\] extends QueryBuilder\ ? \{ \[K in string \| number \| symbol\]: ResultValue\\[K\] \} : never \}\[K\] \}\>\> A function that receives table references and returns the join condition @@ -778,35 +778,96 @@ query ### select() +#### Call Signature + ```ts select(callback): QueryBuilder>>; ``` -Defined in: [packages/db/src/query/builder/index.ts:488](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L488) +Defined in: [packages/db/src/query/builder/index.ts:496](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L496) Select specific columns or computed values from the query -#### Type Parameters +##### Type Parameters -##### TSelectObject +###### TSelectObject `TSelectObject` *extends* `SelectShape` -#### Parameters +##### Parameters -##### callback +###### callback -(`refs`) => `TSelectObject` +(`refs`) => `NonScalarSelectObject`\<`TSelectObject`\> A function that receives table references and returns an object with selected fields or expressions -#### Returns +##### Returns [`QueryBuilder`](../type-aliases/QueryBuilder.md)\<[`WithResult`](../type-aliases/WithResult.md)\<`TContext`, [`ResultTypeFromSelect`](../type-aliases/ResultTypeFromSelect.md)\<`TSelectObject`\>\>\> A QueryBuilder that returns only the selected fields -#### Example +##### Example + +```ts +// Select specific columns +query + .from({ users: usersCollection }) + .select(({users}) => ({ + name: users.name, + email: users.email + })) + +// Select with computed values +query + .from({ users: usersCollection }) + .select(({users}) => ({ + fullName: concat(users.firstName, ' ', users.lastName), + ageInMonths: mul(users.age, 12) + })) + +// Select with aggregates (requires GROUP BY) +query + .from({ posts: postsCollection }) + .groupBy(({posts}) => posts.userId) + .select(({posts, count}) => ({ + userId: posts.userId, + postCount: count(posts.id) + })) +``` + +#### Call Signature + +```ts +select(callback): QueryBuilder>>; +``` + +Defined in: [packages/db/src/query/builder/index.ts:501](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L501) + +Select specific columns or computed values from the query + +##### Type Parameters + +###### TSelectValue + +`TSelectValue` *extends* `ScalarSelectValue` + +##### Parameters + +###### callback + +(`refs`) => `TSelectValue` + +A function that receives table references and returns an object with selected fields or expressions + +##### Returns + +[`QueryBuilder`](../type-aliases/QueryBuilder.md)\<[`WithResult`](../type-aliases/WithResult.md)\<`TContext`, `ResultTypeFromSelectValue`\<`TSelectValue`\>\>\> + +A QueryBuilder that returns only the selected fields + +##### Example ```ts // Select specific columns @@ -843,7 +904,7 @@ query where(callback): QueryBuilder; ``` -Defined in: [packages/db/src/query/builder/index.ts:367](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L367) +Defined in: [packages/db/src/query/builder/index.ts:375](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L375) Filter rows based on a condition diff --git a/docs/reference/classes/BasicIndex.md b/docs/reference/classes/BasicIndex.md new file mode 100644 index 000000000..35df05071 --- /dev/null +++ b/docs/reference/classes/BasicIndex.md @@ -0,0 +1,901 @@ +--- +id: BasicIndex +title: BasicIndex +--- + +# Class: BasicIndex\ + +Defined in: [packages/db/src/indexes/basic-index.ts:39](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L39) + +Basic index using Map + sorted Array. + +- Map for O(1) equality lookups +- Sorted Array for O(log n) range queries via binary search +- O(n) updates to maintain sort order + +Simpler and smaller than BTreeIndex, good for read-heavy workloads. +Use BTreeIndex for write-heavy workloads with large collections. + +## Extends + +- [`BaseIndex`](BaseIndex.md)\<`TKey`\> + +## Type Parameters + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + +## Constructors + +### Constructor + +```ts +new BasicIndex( + id, + expression, + name?, +options?): BasicIndex; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:60](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L60) + +#### Parameters + +##### id + +`number` + +##### expression + +[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md) + +##### name? + +`string` + +##### options? + +`any` + +#### Returns + +`BasicIndex`\<`TKey`\> + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`constructor`](BaseIndex.md#constructor) + +## Properties + +### compareOptions + +```ts +protected compareOptions: CompareOptions; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:92](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L92) + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`compareOptions`](BaseIndex.md#compareoptions) + +*** + +### expression + +```ts +readonly expression: BasicExpression; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:86](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L86) + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`expression`](BaseIndex.md#expression) + +*** + +### id + +```ts +readonly id: number; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:84](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L84) + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`id`](BaseIndex.md#id) + +*** + +### lastUpdated + +```ts +protected lastUpdated: Date; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:91](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L91) + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`lastUpdated`](BaseIndex.md#lastupdated) + +*** + +### lookupCount + +```ts +protected lookupCount: number = 0; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:89](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L89) + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`lookupCount`](BaseIndex.md#lookupcount) + +*** + +### name? + +```ts +readonly optional name: string; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:85](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L85) + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`name`](BaseIndex.md#name) + +*** + +### supportedOperations + +```ts +readonly supportedOperations: Set<"eq" | "gt" | "gte" | "lt" | "lte" | "in" | "like" | "ilike">; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:42](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L42) + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`supportedOperations`](BaseIndex.md#supportedoperations) + +*** + +### totalLookupTime + +```ts +protected totalLookupTime: number = 0; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:90](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L90) + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`totalLookupTime`](BaseIndex.md#totallookuptime) + +## Accessors + +### indexedKeysSet + +#### Get Signature + +```ts +get indexedKeysSet(): Set; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:484](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L484) + +##### Returns + +`Set`\<`TKey`\> + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`indexedKeysSet`](BaseIndex.md#indexedkeysset) + +*** + +### keyCount + +#### Get Signature + +```ts +get keyCount(): number; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:238](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L238) + +Gets the number of indexed keys + +##### Returns + +`number` + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`keyCount`](BaseIndex.md#keycount) + +*** + +### orderedEntriesArray + +#### Get Signature + +```ts +get orderedEntriesArray(): [any, Set][]; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:488](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L488) + +##### Returns + +\[`any`, `Set`\<`TKey`\>\][] + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`orderedEntriesArray`](BaseIndex.md#orderedentriesarray) + +*** + +### orderedEntriesArrayReversed + +#### Get Signature + +```ts +get orderedEntriesArrayReversed(): [any, Set][]; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:495](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L495) + +##### Returns + +\[`any`, `Set`\<`TKey`\>\][] + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`orderedEntriesArrayReversed`](BaseIndex.md#orderedentriesarrayreversed) + +*** + +### valueMapData + +#### Get Signature + +```ts +get valueMapData(): Map>; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:504](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L504) + +##### Returns + +`Map`\<`any`, `Set`\<`TKey`\>\> + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`valueMapData`](BaseIndex.md#valuemapdata) + +## Methods + +### add() + +```ts +add(key, item): void; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:78](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L78) + +Adds a value to the index + +#### Parameters + +##### key + +`TKey` + +##### item + +`any` + +#### Returns + +`void` + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`add`](BaseIndex.md#add) + +*** + +### build() + +```ts +build(entries): void; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:156](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L156) + +Builds the index from a collection of entries + +#### Parameters + +##### entries + +`Iterable`\<\[`TKey`, `any`\]\> + +#### Returns + +`void` + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`build`](BaseIndex.md#build) + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:193](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L193) + +Clears all data from the index + +#### Returns + +`void` + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`clear`](BaseIndex.md#clear) + +*** + +### equalityLookup() + +```ts +equalityLookup(value): Set; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:245](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L245) + +Performs an equality lookup - O(1) + +#### Parameters + +##### value + +`any` + +#### Returns + +`Set`\<`TKey`\> + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`equalityLookup`](BaseIndex.md#equalitylookup) + +*** + +### evaluateIndexExpression() + +```ts +protected evaluateIndexExpression(item): any; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:194](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L194) + +#### Parameters + +##### item + +`any` + +#### Returns + +`any` + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`evaluateIndexExpression`](BaseIndex.md#evaluateindexexpression) + +*** + +### getStats() + +```ts +getStats(): IndexStats; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:182](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L182) + +#### Returns + +[`IndexStats`](../interfaces/IndexStats.md) + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`getStats`](BaseIndex.md#getstats) + +*** + +### inArrayLookup() + +```ts +inArrayLookup(values): Set; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:469](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L469) + +Performs an IN array lookup - O(k) where k is values.length + +#### Parameters + +##### values + +`any`[] + +#### Returns + +`Set`\<`TKey`\> + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`inArrayLookup`](BaseIndex.md#inarraylookup) + +*** + +### initialize() + +```ts +protected initialize(_options?): void; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:73](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L73) + +#### Parameters + +##### \_options? + +[`BasicIndexOptions`](../interfaces/BasicIndexOptions.md) + +#### Returns + +`void` + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`initialize`](BaseIndex.md#initialize) + +*** + +### lookup() + +```ts +lookup(operation, value): Set; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:203](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L203) + +Performs a lookup operation + +#### Parameters + +##### operation + +`"eq"` | `"gt"` | `"gte"` | `"lt"` | `"lte"` | `"in"` | `"like"` | `"ilike"` + +##### value + +`any` + +#### Returns + +`Set`\<`TKey`\> + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`lookup`](BaseIndex.md#lookup) + +*** + +### matchesCompareOptions() + +```ts +matchesCompareOptions(compareOptions): boolean; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:159](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L159) + +Checks if the compare options match the index's compare options. +The direction is ignored because the index can be reversed if the direction is different. + +#### Parameters + +##### compareOptions + +`CompareOptions` + +#### Returns + +`boolean` + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`matchesCompareOptions`](BaseIndex.md#matchescompareoptions) + +*** + +### matchesDirection() + +```ts +matchesDirection(direction): boolean; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:178](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L178) + +Checks if the index matches the provided direction. + +#### Parameters + +##### direction + +[`OrderByDirection`](../@tanstack/namespaces/IR/type-aliases/OrderByDirection.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`matchesDirection`](BaseIndex.md#matchesdirection) + +*** + +### matchesField() + +```ts +matchesField(fieldPath): boolean; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:147](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L147) + +#### Parameters + +##### fieldPath + +`string`[] + +#### Returns + +`boolean` + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`matchesField`](BaseIndex.md#matchesfield) + +*** + +### rangeQuery() + +```ts +rangeQuery(options): Set; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:253](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L253) + +Performs a range query using binary search - O(log n + m) + +#### Parameters + +##### options + +[`RangeQueryOptions`](../interfaces/RangeQueryOptions.md) = `{}` + +#### Returns + +`Set`\<`TKey`\> + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`rangeQuery`](BaseIndex.md#rangequery) + +*** + +### rangeQueryReversed() + +```ts +rangeQueryReversed(options): Set; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:314](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L314) + +Performs a reversed range query + +#### Parameters + +##### options + +[`RangeQueryOptions`](../interfaces/RangeQueryOptions.md) = `{}` + +#### Returns + +`Set`\<`TKey`\> + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`rangeQueryReversed`](BaseIndex.md#rangequeryreversed) + +*** + +### remove() + +```ts +remove(key, item): void; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:114](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L114) + +Removes a value from the index + +#### Parameters + +##### key + +`TKey` + +##### item + +`any` + +#### Returns + +`void` + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`remove`](BaseIndex.md#remove) + +*** + +### supports() + +```ts +supports(operation): boolean; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:143](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L143) + +#### Parameters + +##### operation + +`"eq"` | `"gt"` | `"gte"` | `"lt"` | `"lte"` | `"in"` | `"like"` | `"ilike"` + +#### Returns + +`boolean` + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`supports`](BaseIndex.md#supports) + +*** + +### take() + +```ts +take( + n, + from?, + filterFn?): TKey[]; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:339](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L339) + +Returns the next n items in sorted order + +#### Parameters + +##### n + +`number` + +##### from? + +`any` + +##### filterFn? + +(`key`) => `boolean` + +#### Returns + +`TKey`[] + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`take`](BaseIndex.md#take) + +*** + +### takeFromStart() + +```ts +takeFromStart(n, filterFn?): TKey[]; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:424](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L424) + +Returns the first n items in sorted order (from the start) + +#### Parameters + +##### n + +`number` + +##### filterFn? + +(`key`) => `boolean` + +#### Returns + +`TKey`[] + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`takeFromStart`](BaseIndex.md#takefromstart) + +*** + +### takeReversed() + +```ts +takeReversed( + n, + from?, + filterFn?): TKey[]; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:381](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L381) + +Returns the next n items in reverse sorted order + +#### Parameters + +##### n + +`number` + +##### from? + +`any` + +##### filterFn? + +(`key`) => `boolean` + +#### Returns + +`TKey`[] + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`takeReversed`](BaseIndex.md#takereversed) + +*** + +### takeReversedFromEnd() + +```ts +takeReversedFromEnd(n, filterFn?): TKey[]; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:443](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L443) + +Returns the first n items in reverse sorted order (from the end) + +#### Parameters + +##### n + +`number` + +##### filterFn? + +(`key`) => `boolean` + +#### Returns + +`TKey`[] + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`takeReversedFromEnd`](BaseIndex.md#takereversedfromend) + +*** + +### trackLookup() + +```ts +protected trackLookup(startTime): void; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:199](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L199) + +#### Parameters + +##### startTime + +`number` + +#### Returns + +`void` + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`trackLookup`](BaseIndex.md#tracklookup) + +*** + +### update() + +```ts +update( + key, + oldItem, + newItem): void; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:148](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L148) + +Updates a value in the index + +#### Parameters + +##### key + +`TKey` + +##### oldItem + +`any` + +##### newItem + +`any` + +#### Returns + +`void` + +#### Overrides + +[`BaseIndex`](BaseIndex.md).[`update`](BaseIndex.md#update) + +*** + +### updateTimestamp() + +```ts +protected updateTimestamp(): void; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:205](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L205) + +#### Returns + +`void` + +#### Inherited from + +[`BaseIndex`](BaseIndex.md).[`updateTimestamp`](BaseIndex.md#updatetimestamp) diff --git a/docs/reference/classes/CannotCombineEmptyExpressionListError.md b/docs/reference/classes/CannotCombineEmptyExpressionListError.md index 555b41924..121f7481d 100644 --- a/docs/reference/classes/CannotCombineEmptyExpressionListError.md +++ b/docs/reference/classes/CannotCombineEmptyExpressionListError.md @@ -5,7 +5,7 @@ title: CannotCombineEmptyExpressionListError # Class: CannotCombineEmptyExpressionListError -Defined in: [packages/db/src/errors.ts:684](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L684) +Defined in: [packages/db/src/errors.ts:693](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L693) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:684](https://github.com/TanStack/db/blob/ new CannotCombineEmptyExpressionListError(): CannotCombineEmptyExpressionListError; ``` -Defined in: [packages/db/src/errors.ts:685](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L685) +Defined in: [packages/db/src/errors.ts:694](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L694) #### Returns diff --git a/docs/reference/classes/CollectionImpl.md b/docs/reference/classes/CollectionImpl.md index ea6fb1f45..18c8c74d6 100644 --- a/docs/reference/classes/CollectionImpl.md +++ b/docs/reference/classes/CollectionImpl.md @@ -5,7 +5,7 @@ title: CollectionImpl # Class: CollectionImpl\ -Defined in: [packages/db/src/collection/index.ts:266](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L266) +Defined in: [packages/db/src/collection/index.ts:272](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L272) ## Extended by @@ -42,7 +42,7 @@ Defined in: [packages/db/src/collection/index.ts:266](https://github.com/TanStac new CollectionImpl(config): CollectionImpl; ``` -Defined in: [packages/db/src/collection/index.ts:305](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L305) +Defined in: [packages/db/src/collection/index.ts:318](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L318) Creates a new Collection instance @@ -70,7 +70,7 @@ Error if sync config is missing _lifecycle: CollectionLifecycleManager; ``` -Defined in: [packages/db/src/collection/index.ts:283](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L283) +Defined in: [packages/db/src/collection/index.ts:289](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L289) *** @@ -80,7 +80,7 @@ Defined in: [packages/db/src/collection/index.ts:283](https://github.com/TanStac _state: CollectionStateManager; ``` -Defined in: [packages/db/src/collection/index.ts:295](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L295) +Defined in: [packages/db/src/collection/index.ts:301](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L301) *** @@ -90,7 +90,7 @@ Defined in: [packages/db/src/collection/index.ts:295](https://github.com/TanStac _sync: CollectionSyncManager; ``` -Defined in: [packages/db/src/collection/index.ts:284](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L284) +Defined in: [packages/db/src/collection/index.ts:290](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L290) *** @@ -100,7 +100,21 @@ Defined in: [packages/db/src/collection/index.ts:284](https://github.com/TanStac config: CollectionConfig; ``` -Defined in: [packages/db/src/collection/index.ts:274](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L274) +Defined in: [packages/db/src/collection/index.ts:280](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L280) + +*** + +### deferDataRefresh + +```ts +deferDataRefresh: Promise | null = null; +``` + +Defined in: [packages/db/src/collection/index.ts:308](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L308) + +When set, collection consumers should defer processing incoming data +refreshes until this promise resolves. This prevents stale data from +overwriting optimistic state while pending writes are being applied. *** @@ -110,7 +124,7 @@ Defined in: [packages/db/src/collection/index.ts:274](https://github.com/TanStac id: string; ``` -Defined in: [packages/db/src/collection/index.ts:273](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L273) +Defined in: [packages/db/src/collection/index.ts:279](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L279) *** @@ -120,7 +134,7 @@ Defined in: [packages/db/src/collection/index.ts:273](https://github.com/TanStac utils: Record = {}; ``` -Defined in: [packages/db/src/collection/index.ts:278](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L278) +Defined in: [packages/db/src/collection/index.ts:284](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L284) ## Accessors @@ -132,7 +146,7 @@ Defined in: [packages/db/src/collection/index.ts:278](https://github.com/TanStac get compareOptions(): StringCollationConfig; ``` -Defined in: [packages/db/src/collection/index.ts:580](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L580) +Defined in: [packages/db/src/collection/index.ts:643](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L643) ##### Returns @@ -148,7 +162,7 @@ Defined in: [packages/db/src/collection/index.ts:580](https://github.com/TanStac get indexes(): Map>; ``` -Defined in: [packages/db/src/collection/index.ts:565](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L565) +Defined in: [packages/db/src/collection/index.ts:628](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L628) Get resolved indexes for query optimization @@ -166,7 +180,7 @@ Get resolved indexes for query optimization get isLoadingSubset(): boolean; ``` -Defined in: [packages/db/src/collection/index.ts:431](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L431) +Defined in: [packages/db/src/collection/index.ts:456](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L456) Check if the collection is currently loading more data @@ -186,7 +200,7 @@ true if the collection has pending load more operations, false otherwise get size(): number; ``` -Defined in: [packages/db/src/collection/index.ts:468](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L468) +Defined in: [packages/db/src/collection/index.ts:493](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L493) Get the current size of the collection (cached) @@ -201,10 +215,10 @@ Get the current size of the collection (cached) #### Get Signature ```ts -get state(): Map; +get state(): Map>; ``` -Defined in: [packages/db/src/collection/index.ts:757](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L757) +Defined in: [packages/db/src/collection/index.ts:820](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L820) Gets the current state of the collection as a Map @@ -226,7 +240,7 @@ if (itemsMap.has("todo-1")) { ##### Returns -`Map`\<`TKey`, `TOutput`\> +`Map`\<`TKey`, [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\>\> Map containing all items in the collection, with keys as identifiers @@ -240,7 +254,7 @@ Map containing all items in the collection, with keys as identifiers get status(): CollectionStatus; ``` -Defined in: [packages/db/src/collection/index.ts:386](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L386) +Defined in: [packages/db/src/collection/index.ts:411](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L411) Gets the current status of the collection @@ -258,7 +272,7 @@ Gets the current status of the collection get subscriberCount(): number; ``` -Defined in: [packages/db/src/collection/index.ts:393](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L393) +Defined in: [packages/db/src/collection/index.ts:418](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L418) Get the number of subscribers to the collection @@ -273,16 +287,16 @@ Get the number of subscribers to the collection #### Get Signature ```ts -get toArray(): TOutput[]; +get toArray(): WithVirtualProps[]; ``` -Defined in: [packages/db/src/collection/index.ts:786](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L786) +Defined in: [packages/db/src/collection/index.ts:849](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L849) Gets the current state of the collection as an Array ##### Returns -`TOutput`[] +[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\>[] An Array containing all items in the collection @@ -291,16 +305,16 @@ An Array containing all items in the collection ### \[iterator\]() ```ts -iterator: IterableIterator<[TKey, TOutput]>; +iterator: IterableIterator<[TKey, WithVirtualProps]>; ``` -Defined in: [packages/db/src/collection/index.ts:496](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L496) +Defined in: [packages/db/src/collection/index.ts:531](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L531) Get all entries (virtual derived state) #### Returns -`IterableIterator`\<\[`TKey`, `TOutput`\]\> +`IterableIterator`\<\[`TKey`, [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\>\]\> *** @@ -310,7 +324,7 @@ Get all entries (virtual derived state) cleanup(): Promise; ``` -Defined in: [packages/db/src/collection/index.ts:923](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L923) +Defined in: [packages/db/src/collection/index.ts:988](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L988) Clean up the collection by stopping sync and clearing data This can be called manually or automatically by garbage collection @@ -324,10 +338,10 @@ This can be called manually or automatically by garbage collection ### createIndex() ```ts -createIndex(indexCallback, config): IndexProxy; +createIndex(indexCallback, config): BaseIndex; ``` -Defined in: [packages/db/src/collection/index.ts:555](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L555) +Defined in: [packages/db/src/collection/index.ts:597](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L597) Creates an index on a collection for faster queries. Indexes significantly improve query performance by allowing constant time lookups @@ -335,11 +349,9 @@ and logarithmic time range queries instead of full scans. #### Type Parameters -##### TResolver - -`TResolver` *extends* [`IndexResolver`](../type-aliases/IndexResolver.md)\<`TKey`\> = *typeof* [`BTreeIndex`](BTreeIndex.md) +##### TIndexType -The type of the index resolver (constructor or async loader) +`TIndexType` *extends* [`IndexConstructor`](../type-aliases/IndexConstructor.md)\<`TKey`\> #### Parameters @@ -351,40 +363,28 @@ Function that extracts the indexed value from each item ##### config -[`IndexOptions`](../interfaces/IndexOptions.md)\<`TResolver`\> = `{}` +[`IndexOptions`](../interfaces/IndexOptions.md)\<`TIndexType`\> = `{}` Configuration including index type and type-specific options #### Returns -[`IndexProxy`](IndexProxy.md)\<`TKey`\> +[`BaseIndex`](BaseIndex.md)\<`TKey`\> -An index proxy that provides access to the index when ready +The created index #### Example ```ts -// Create a default B+ tree index -const ageIndex = collection.createIndex((row) => row.age) +import { BasicIndex } from '@tanstack/db' -// Create a ordered index with custom options +// Create an index with explicit type const ageIndex = collection.createIndex((row) => row.age, { - indexType: BTreeIndex, - options: { - compareFn: customComparator, - compareOptions: { direction: 'asc', nulls: 'first', stringSort: 'lexical' } - }, - name: 'age_btree' + indexType: BasicIndex }) -// Create an async-loaded index -const textIndex = collection.createIndex((row) => row.content, { - indexType: async () => { - const { FullTextIndex } = await import('./indexes/fulltext.js') - return FullTextIndex - }, - options: { language: 'en' } -}) +// Create an index with collection's default type +const nameIndex = collection.createIndex((row) => row.name) ``` *** @@ -394,10 +394,10 @@ const textIndex = collection.createIndex((row) => row.content, { ```ts currentStateAsChanges(options): | void - | ChangeMessage[]; + | ChangeMessage, string | number>[]; ``` -Defined in: [packages/db/src/collection/index.ts:824](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L824) +Defined in: [packages/db/src/collection/index.ts:887](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L887) Returns the current state of the collection as an array of changes @@ -412,7 +412,7 @@ Options including optional where filter #### Returns \| `void` - \| [`ChangeMessage`](../interfaces/ChangeMessage.md)\<`TOutput`, `string` \| `number`\>[] + \| [`ChangeMessage`](../interfaces/ChangeMessage.md)\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\>, `string` \| `number`\>[] An array of changes @@ -441,7 +441,7 @@ const activeChanges = collection.currentStateAsChanges({ delete(keys, config?): Transaction; ``` -Defined in: [packages/db/src/collection/index.ts:734](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L734) +Defined in: [packages/db/src/collection/index.ts:797](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L797) Deletes one or more items from the collection @@ -501,16 +501,16 @@ try { ### entries() ```ts -entries(): IterableIterator<[TKey, TOutput]>; +entries(): IterableIterator<[TKey, WithVirtualProps]>; ``` -Defined in: [packages/db/src/collection/index.ts:489](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L489) +Defined in: [packages/db/src/collection/index.ts:519](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L519) Get all entries (virtual derived state) #### Returns -`IterableIterator`\<\[`TKey`, `TOutput`\]\> +`IterableIterator`\<\[`TKey`, [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\>\]\> *** @@ -520,7 +520,7 @@ Get all entries (virtual derived state) forEach(callbackfn): void; ``` -Defined in: [packages/db/src/collection/index.ts:503](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L503) +Defined in: [packages/db/src/collection/index.ts:540](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L540) Execute a callback for each entry in the collection @@ -539,10 +539,12 @@ Execute a callback for each entry in the collection ### get() ```ts -get(key): TOutput | undefined; +get(key): + | WithVirtualProps + | undefined; ``` -Defined in: [packages/db/src/collection/index.ts:454](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L454) +Defined in: [packages/db/src/collection/index.ts:479](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L479) Get the current value for a key (virtual derived state) @@ -554,7 +556,26 @@ Get the current value for a key (virtual derived state) #### Returns -`TOutput` \| `undefined` + \| [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\> + \| `undefined` + +*** + +### getIndexMetadata() + +```ts +getIndexMetadata(): CollectionIndexMetadata[]; +``` + +Defined in: [packages/db/src/collection/index.ts:621](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L621) + +Returns a snapshot of current index metadata sorted by indexId. +Persistence wrappers can use this to bootstrap index state if indexes were +created before event listeners were attached. + +#### Returns + +[`CollectionIndexMetadata`](../interfaces/CollectionIndexMetadata.md)[] *** @@ -564,7 +585,7 @@ Get the current value for a key (virtual derived state) getKeyFromItem(item): TKey; ``` -Defined in: [packages/db/src/collection/index.ts:518](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L518) +Defined in: [packages/db/src/collection/index.ts:571](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L571) #### Parameters @@ -584,7 +605,7 @@ Defined in: [packages/db/src/collection/index.ts:518](https://github.com/TanStac has(key): boolean; ``` -Defined in: [packages/db/src/collection/index.ts:461](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L461) +Defined in: [packages/db/src/collection/index.ts:486](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L486) Check if a key exists in the collection (virtual derived state) @@ -606,7 +627,7 @@ Check if a key exists in the collection (virtual derived state) insert(data, config?): Transaction>; ``` -Defined in: [packages/db/src/collection/index.ts:621](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L621) +Defined in: [packages/db/src/collection/index.ts:684](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L684) Inserts one or more items into the collection @@ -676,7 +697,7 @@ try { isReady(): boolean; ``` -Defined in: [packages/db/src/collection/index.ts:423](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L423) +Defined in: [packages/db/src/collection/index.ts:448](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L448) Check if the collection is ready for use Returns true if the collection has been marked as ready by its sync implementation @@ -706,7 +727,7 @@ if (collection.isReady()) { keys(): IterableIterator; ``` -Defined in: [packages/db/src/collection/index.ts:475](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L475) +Defined in: [packages/db/src/collection/index.ts:500](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L500) Get all keys (virtual derived state) @@ -722,7 +743,7 @@ Get all keys (virtual derived state) map(callbackfn): U[]; ``` -Defined in: [packages/db/src/collection/index.ts:512](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L512) +Defined in: [packages/db/src/collection/index.ts:556](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L556) Create a new array with the results of calling a function for each entry in the collection @@ -750,7 +771,7 @@ Create a new array with the results of calling a function for each entry in the off(event, callback): void; ``` -Defined in: [packages/db/src/collection/index.ts:902](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L902) +Defined in: [packages/db/src/collection/index.ts:967](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L967) Unsubscribe from a collection event @@ -768,6 +789,8 @@ Unsubscribe from a collection event \| `"subscribers:change"` \| `"loadingSubset:change"` \| `"truncate"` + \| `"index:added"` + \| `"index:removed"` #### Parameters @@ -791,7 +814,7 @@ Unsubscribe from a collection event on(event, callback): () => void; ``` -Defined in: [packages/db/src/collection/index.ts:882](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L882) +Defined in: [packages/db/src/collection/index.ts:947](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L947) Subscribe to a collection event @@ -809,6 +832,8 @@ Subscribe to a collection event \| `"subscribers:change"` \| `"loadingSubset:change"` \| `"truncate"` + \| `"index:added"` + \| `"index:removed"` #### Parameters @@ -838,7 +863,7 @@ Subscribe to a collection event once(event, callback): () => void; ``` -Defined in: [packages/db/src/collection/index.ts:892](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L892) +Defined in: [packages/db/src/collection/index.ts:957](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L957) Subscribe to a collection event once @@ -856,6 +881,8 @@ Subscribe to a collection event once \| `"subscribers:change"` \| `"loadingSubset:change"` \| `"truncate"` + \| `"index:added"` + \| `"index:removed"` #### Parameters @@ -885,7 +912,7 @@ Subscribe to a collection event once onFirstReady(callback): void; ``` -Defined in: [packages/db/src/collection/index.ts:407](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L407) +Defined in: [packages/db/src/collection/index.ts:432](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L432) Register a callback to be executed when the collection first becomes ready Useful for preloading collections @@ -919,7 +946,7 @@ collection.onFirstReady(() => { preload(): Promise; ``` -Defined in: [packages/db/src/collection/index.ts:447](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L447) +Defined in: [packages/db/src/collection/index.ts:472](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L472) Preload the collection data by starting sync if not already started Multiple concurrent calls will share the same promise @@ -930,13 +957,40 @@ Multiple concurrent calls will share the same promise *** +### removeIndex() + +```ts +removeIndex(indexOrId): boolean; +``` + +Defined in: [packages/db/src/collection/index.ts:612](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L612) + +Removes an index created with createIndex. +Returns true when an index existed and was removed. + +Best-effort semantics: removing an index guarantees it is detached from +collection query planning. Existing index proxy references should be treated +as invalid after removal. + +#### Parameters + +##### indexOrId + +`number` | [`BaseIndex`](BaseIndex.md)\<`TKey`\> + +#### Returns + +`boolean` + +*** + ### startSyncImmediate() ```ts startSyncImmediate(): void; ``` -Defined in: [packages/db/src/collection/index.ts:439](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L439) +Defined in: [packages/db/src/collection/index.ts:464](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L464) Start sync immediately - internal method for compiled queries This bypasses lazy loading for special cases like live query results @@ -950,17 +1004,17 @@ This bypasses lazy loading for special cases like live query results ### stateWhenReady() ```ts -stateWhenReady(): Promise>; +stateWhenReady(): Promise>>; ``` -Defined in: [packages/db/src/collection/index.ts:771](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L771) +Defined in: [packages/db/src/collection/index.ts:834](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L834) Gets the current state of the collection as a Map, but only resolves when data is available Waits for the first sync commit to complete before resolving #### Returns -`Promise`\<`Map`\<`TKey`, `TOutput`\>\> +`Promise`\<`Map`\<`TKey`, [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\>\>\> Promise that resolves to a Map containing all items in the collection @@ -972,7 +1026,7 @@ Promise that resolves to a Map containing all items in the collection subscribeChanges(callback, options): CollectionSubscription; ``` -Defined in: [packages/db/src/collection/index.ts:872](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L872) +Defined in: [packages/db/src/collection/index.ts:935](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L935) Subscribe to changes in the collection @@ -986,7 +1040,7 @@ Function called when items change ##### options -[`SubscribeChangesOptions`](../interfaces/SubscribeChangesOptions.md)\<`TOutput`\> = `{}` +[`SubscribeChangesOptions`](../interfaces/SubscribeChangesOptions.md)\<`TOutput`, `TKey`\> = `{}` Subscription options including includeInitialState and where filter @@ -1044,17 +1098,17 @@ const subscription = collection.subscribeChanges((changes) => { ### toArrayWhenReady() ```ts -toArrayWhenReady(): Promise; +toArrayWhenReady(): Promise[]>; ``` -Defined in: [packages/db/src/collection/index.ts:796](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L796) +Defined in: [packages/db/src/collection/index.ts:859](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L859) Gets the current state of the collection as an Array, but only resolves when data is available Waits for the first sync commit to complete before resolving #### Returns -`Promise`\<`TOutput`[]\> +`Promise`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\>[]\> Promise that resolves to an Array containing all items in the collection @@ -1068,7 +1122,7 @@ Promise that resolves to an Array containing all items in the collection update(key, callback): Transaction; ``` -Defined in: [packages/db/src/collection/index.ts:666](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L666) +Defined in: [packages/db/src/collection/index.ts:729](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L729) Updates one or more items in the collection using a callback function @@ -1139,7 +1193,7 @@ update( callback): Transaction; ``` -Defined in: [packages/db/src/collection/index.ts:672](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L672) +Defined in: [packages/db/src/collection/index.ts:735](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L735) Updates one or more items in the collection using a callback function @@ -1213,7 +1267,7 @@ try { update(id, callback): Transaction; ``` -Defined in: [packages/db/src/collection/index.ts:679](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L679) +Defined in: [packages/db/src/collection/index.ts:742](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L742) Updates one or more items in the collection using a callback function @@ -1284,7 +1338,7 @@ update( callback): Transaction; ``` -Defined in: [packages/db/src/collection/index.ts:685](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L685) +Defined in: [packages/db/src/collection/index.ts:748](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L748) Updates one or more items in the collection using a callback function @@ -1361,7 +1415,7 @@ validateData( key?): TOutput; ``` -Defined in: [packages/db/src/collection/index.ts:572](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L572) +Defined in: [packages/db/src/collection/index.ts:635](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L635) Validates the data against the schema @@ -1388,16 +1442,16 @@ Validates the data against the schema ### values() ```ts -values(): IterableIterator; +values(): IterableIterator>; ``` -Defined in: [packages/db/src/collection/index.ts:482](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L482) +Defined in: [packages/db/src/collection/index.ts:507](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L507) Get all values (virtual derived state) #### Returns -`IterableIterator`\<`TOutput`\> +`IterableIterator`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\>\> *** @@ -1407,7 +1461,7 @@ Get all values (virtual derived state) waitFor(event, timeout?): Promise; ``` -Defined in: [packages/db/src/collection/index.ts:912](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L912) +Defined in: [packages/db/src/collection/index.ts:977](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L977) Wait for a collection event @@ -1425,6 +1479,8 @@ Wait for a collection event \| `"subscribers:change"` \| `"loadingSubset:change"` \| `"truncate"` + \| `"index:added"` + \| `"index:removed"` #### Parameters diff --git a/docs/reference/classes/CollectionInputNotFoundError.md b/docs/reference/classes/CollectionInputNotFoundError.md index adf1889ea..b2d75b3f5 100644 --- a/docs/reference/classes/CollectionInputNotFoundError.md +++ b/docs/reference/classes/CollectionInputNotFoundError.md @@ -5,7 +5,7 @@ title: CollectionInputNotFoundError # Class: CollectionInputNotFoundError -Defined in: [packages/db/src/errors.ts:465](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L465) +Defined in: [packages/db/src/errors.ts:474](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L474) 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. @@ -25,7 +25,7 @@ new CollectionInputNotFoundError( availableKeys?): CollectionInputNotFoundError; ``` -Defined in: [packages/db/src/errors.ts:466](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L466) +Defined in: [packages/db/src/errors.ts:475](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L475) #### Parameters diff --git a/docs/reference/classes/DeduplicatedLoadSubset.md b/docs/reference/classes/DeduplicatedLoadSubset.md index 51cc5a395..eb0a80f79 100644 --- a/docs/reference/classes/DeduplicatedLoadSubset.md +++ b/docs/reference/classes/DeduplicatedLoadSubset.md @@ -106,7 +106,7 @@ true if data is already loaded, or a Promise that resolves when data is loaded reset(): void; ``` -Defined in: [packages/db/src/query/subset-dedupe.ts:197](https://github.com/TanStack/db/blob/main/packages/db/src/query/subset-dedupe.ts#L197) +Defined in: [packages/db/src/query/subset-dedupe.ts:194](https://github.com/TanStack/db/blob/main/packages/db/src/query/subset-dedupe.ts#L194) Reset all tracking state. Clears the history of loaded predicates and in-flight calls. diff --git a/docs/reference/classes/DuplicateAliasInSubqueryError.md b/docs/reference/classes/DuplicateAliasInSubqueryError.md index 609eb0f3e..d32ef272f 100644 --- a/docs/reference/classes/DuplicateAliasInSubqueryError.md +++ b/docs/reference/classes/DuplicateAliasInSubqueryError.md @@ -5,7 +5,7 @@ title: DuplicateAliasInSubqueryError # Class: DuplicateAliasInSubqueryError -Defined in: [packages/db/src/errors.ts:486](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L486) +Defined in: [packages/db/src/errors.ts:495](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L495) 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, @@ -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:487](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L487) +Defined in: [packages/db/src/errors.ts:496](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L496) #### Parameters diff --git a/docs/reference/classes/EmptyReferencePathError.md b/docs/reference/classes/EmptyReferencePathError.md index 63c0934a6..2b5583daa 100644 --- a/docs/reference/classes/EmptyReferencePathError.md +++ b/docs/reference/classes/EmptyReferencePathError.md @@ -5,7 +5,7 @@ title: EmptyReferencePathError # Class: EmptyReferencePathError -Defined in: [packages/db/src/errors.ts:509](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L509) +Defined in: [packages/db/src/errors.ts:518](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L518) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:509](https://github.com/TanStack/db/blob/ new EmptyReferencePathError(): EmptyReferencePathError; ``` -Defined in: [packages/db/src/errors.ts:510](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L510) +Defined in: [packages/db/src/errors.ts:519](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L519) #### Returns diff --git a/docs/reference/classes/GroupByError.md b/docs/reference/classes/GroupByError.md index ca75a2eb3..c010300fb 100644 --- a/docs/reference/classes/GroupByError.md +++ b/docs/reference/classes/GroupByError.md @@ -5,7 +5,7 @@ title: GroupByError # Class: GroupByError -Defined in: [packages/db/src/errors.ts:584](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L584) +Defined in: [packages/db/src/errors.ts:593](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L593) ## Extends @@ -26,7 +26,7 @@ Defined in: [packages/db/src/errors.ts:584](https://github.com/TanStack/db/blob/ new GroupByError(message): GroupByError; ``` -Defined in: [packages/db/src/errors.ts:585](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L585) +Defined in: [packages/db/src/errors.ts:594](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L594) #### Parameters diff --git a/docs/reference/classes/HavingRequiresGroupByError.md b/docs/reference/classes/HavingRequiresGroupByError.md index 7610d4d6d..bbf7cdb8f 100644 --- a/docs/reference/classes/HavingRequiresGroupByError.md +++ b/docs/reference/classes/HavingRequiresGroupByError.md @@ -5,7 +5,7 @@ title: HavingRequiresGroupByError # Class: HavingRequiresGroupByError -Defined in: [packages/db/src/errors.ts:447](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L447) +Defined in: [packages/db/src/errors.ts:456](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L456) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:447](https://github.com/TanStack/db/blob/ new HavingRequiresGroupByError(): HavingRequiresGroupByError; ``` -Defined in: [packages/db/src/errors.ts:448](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L448) +Defined in: [packages/db/src/errors.ts:457](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L457) #### Returns diff --git a/docs/reference/classes/IndexProxy.md b/docs/reference/classes/IndexProxy.md deleted file mode 100644 index 203620ae0..000000000 --- a/docs/reference/classes/IndexProxy.md +++ /dev/null @@ -1,346 +0,0 @@ ---- -id: IndexProxy -title: IndexProxy ---- - -# Class: IndexProxy\ - -Defined in: [packages/db/src/indexes/lazy-index.ts:131](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L131) - -Proxy that provides synchronous interface while index loads asynchronously - -## Type Parameters - -### TKey - -`TKey` *extends* `string` \| `number` = `string` \| `number` - -## Constructors - -### Constructor - -```ts -new IndexProxy(indexId, lazyIndex): IndexProxy; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:132](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L132) - -#### Parameters - -##### indexId - -`number` - -##### lazyIndex - -[`LazyIndexWrapper`](LazyIndexWrapper.md)\<`TKey`\> - -#### Returns - -`IndexProxy`\<`TKey`\> - -## Accessors - -### expression - -#### Get Signature - -```ts -get expression(): BasicExpression; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:178](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L178) - -Get the index expression (available immediately) - -##### Returns - -[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md) - -*** - -### id - -#### Get Signature - -```ts -get id(): number; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:161](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L161) - -Get the index ID - -##### Returns - -`number` - -*** - -### index - -#### Get Signature - -```ts -get index(): BaseIndex; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:140](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L140) - -Get the resolved index (throws if not ready) - -##### Returns - -[`BaseIndex`](BaseIndex.md)\<`TKey`\> - -*** - -### indexedKeysSet - -#### Get Signature - -```ts -get indexedKeysSet(): Set; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:216](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L216) - -##### Returns - -`Set`\<`TKey`\> - -*** - -### isReady - -#### Get Signature - -```ts -get isReady(): boolean; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:147](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L147) - -Check if index is ready - -##### Returns - -`boolean` - -*** - -### keyCount - -#### Get Signature - -```ts -get keyCount(): number; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:211](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L211) - -Get the key count (throws if not ready) - -##### Returns - -`number` - -*** - -### name - -#### Get Signature - -```ts -get name(): string | undefined; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:168](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L168) - -Get the index name (throws if not ready) - -##### Returns - -`string` \| `undefined` - -*** - -### orderedEntriesArray - -#### Get Signature - -```ts -get orderedEntriesArray(): [any, Set][]; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:221](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L221) - -##### Returns - -\[`any`, `Set`\<`TKey`\>\][] - -*** - -### valueMapData - -#### Get Signature - -```ts -get valueMapData(): Map>; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:226](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L226) - -##### Returns - -`Map`\<`any`, `Set`\<`TKey`\>\> - -## Methods - -### \_getLazyWrapper() - -```ts -_getLazyWrapper(): LazyIndexWrapper; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:248](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L248) - -#### Returns - -[`LazyIndexWrapper`](LazyIndexWrapper.md)\<`TKey`\> - -*** - -### equalityLookup() - -```ts -equalityLookup(value): Set; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:232](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L232) - -#### Parameters - -##### value - -`any` - -#### Returns - -`Set`\<`TKey`\> - -*** - -### getStats() - -```ts -getStats(): IndexStats; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:192](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L192) - -Get index statistics (throws if not ready) - -#### Returns - -[`IndexStats`](../interfaces/IndexStats.md) - -*** - -### inArrayLookup() - -```ts -inArrayLookup(values): Set; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:242](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L242) - -#### Parameters - -##### values - -`any`[] - -#### Returns - -`Set`\<`TKey`\> - -*** - -### matchesField() - -```ts -matchesField(fieldPath): boolean; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:199](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L199) - -Check if index matches a field path (available immediately) - -#### Parameters - -##### fieldPath - -`string`[] - -#### Returns - -`boolean` - -*** - -### rangeQuery() - -```ts -rangeQuery(options): Set; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:237](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L237) - -#### Parameters - -##### options - -`any` - -#### Returns - -`Set`\<`TKey`\> - -*** - -### supports() - -```ts -supports(operation): boolean; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:185](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L185) - -Check if index supports an operation (throws if not ready) - -#### Parameters - -##### operation - -`any` - -#### Returns - -`boolean` - -*** - -### whenReady() - -```ts -whenReady(): Promise>; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:154](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L154) - -Wait for index to be ready - -#### Returns - -`Promise`\<[`BaseIndex`](BaseIndex.md)\<`TKey`\>\> diff --git a/docs/reference/classes/InvalidJoinCondition.md b/docs/reference/classes/InvalidJoinCondition.md index 96f0379ec..777521bdc 100644 --- a/docs/reference/classes/InvalidJoinCondition.md +++ b/docs/reference/classes/InvalidJoinCondition.md @@ -5,7 +5,7 @@ title: InvalidJoinCondition # Class: InvalidJoinCondition -Defined in: [packages/db/src/errors.ts:571](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L571) +Defined in: [packages/db/src/errors.ts:580](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L580) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:571](https://github.com/TanStack/db/blob/ new InvalidJoinCondition(): InvalidJoinCondition; ``` -Defined in: [packages/db/src/errors.ts:572](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L572) +Defined in: [packages/db/src/errors.ts:581](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L581) #### Returns diff --git a/docs/reference/classes/InvalidJoinConditionLeftSourceError.md b/docs/reference/classes/InvalidJoinConditionLeftSourceError.md index d1a15160e..2c6c6257d 100644 --- a/docs/reference/classes/InvalidJoinConditionLeftSourceError.md +++ b/docs/reference/classes/InvalidJoinConditionLeftSourceError.md @@ -5,7 +5,7 @@ title: InvalidJoinConditionLeftSourceError # Class: InvalidJoinConditionLeftSourceError -Defined in: [packages/db/src/errors.ts:555](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L555) +Defined in: [packages/db/src/errors.ts:564](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L564) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:555](https://github.com/TanStack/db/blob/ new InvalidJoinConditionLeftSourceError(sourceAlias): InvalidJoinConditionLeftSourceError; ``` -Defined in: [packages/db/src/errors.ts:556](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L556) +Defined in: [packages/db/src/errors.ts:565](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L565) #### Parameters diff --git a/docs/reference/classes/InvalidJoinConditionRightSourceError.md b/docs/reference/classes/InvalidJoinConditionRightSourceError.md index 6880e93ed..92f28a956 100644 --- a/docs/reference/classes/InvalidJoinConditionRightSourceError.md +++ b/docs/reference/classes/InvalidJoinConditionRightSourceError.md @@ -5,7 +5,7 @@ title: InvalidJoinConditionRightSourceError # Class: InvalidJoinConditionRightSourceError -Defined in: [packages/db/src/errors.ts:563](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L563) +Defined in: [packages/db/src/errors.ts:572](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L572) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:563](https://github.com/TanStack/db/blob/ new InvalidJoinConditionRightSourceError(sourceAlias): InvalidJoinConditionRightSourceError; ``` -Defined in: [packages/db/src/errors.ts:564](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L564) +Defined in: [packages/db/src/errors.ts:573](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L573) #### Parameters diff --git a/docs/reference/classes/InvalidJoinConditionSameSourceError.md b/docs/reference/classes/InvalidJoinConditionSameSourceError.md index b72feb37b..8b20d62b3 100644 --- a/docs/reference/classes/InvalidJoinConditionSameSourceError.md +++ b/docs/reference/classes/InvalidJoinConditionSameSourceError.md @@ -5,7 +5,7 @@ title: InvalidJoinConditionSameSourceError # Class: InvalidJoinConditionSameSourceError -Defined in: [packages/db/src/errors.ts:541](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L541) +Defined in: [packages/db/src/errors.ts:550](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L550) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:541](https://github.com/TanStack/db/blob/ new InvalidJoinConditionSameSourceError(sourceAlias): InvalidJoinConditionSameSourceError; ``` -Defined in: [packages/db/src/errors.ts:542](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L542) +Defined in: [packages/db/src/errors.ts:551](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L551) #### Parameters diff --git a/docs/reference/classes/InvalidJoinConditionSourceMismatchError.md b/docs/reference/classes/InvalidJoinConditionSourceMismatchError.md index b2d23c0a0..3978012ae 100644 --- a/docs/reference/classes/InvalidJoinConditionSourceMismatchError.md +++ b/docs/reference/classes/InvalidJoinConditionSourceMismatchError.md @@ -5,7 +5,7 @@ title: InvalidJoinConditionSourceMismatchError # Class: InvalidJoinConditionSourceMismatchError -Defined in: [packages/db/src/errors.ts:549](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L549) +Defined in: [packages/db/src/errors.ts:558](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L558) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:549](https://github.com/TanStack/db/blob/ new InvalidJoinConditionSourceMismatchError(): InvalidJoinConditionSourceMismatchError; ``` -Defined in: [packages/db/src/errors.ts:550](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L550) +Defined in: [packages/db/src/errors.ts:559](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L559) #### Returns diff --git a/docs/reference/classes/InvalidStorageDataFormatError.md b/docs/reference/classes/InvalidStorageDataFormatError.md index 5bb25ffed..c7ec40856 100644 --- a/docs/reference/classes/InvalidStorageDataFormatError.md +++ b/docs/reference/classes/InvalidStorageDataFormatError.md @@ -5,7 +5,7 @@ title: InvalidStorageDataFormatError # Class: InvalidStorageDataFormatError -Defined in: [packages/db/src/errors.ts:649](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L649) +Defined in: [packages/db/src/errors.ts:658](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L658) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:649](https://github.com/TanStack/db/blob/ new InvalidStorageDataFormatError(storageKey, key): InvalidStorageDataFormatError; ``` -Defined in: [packages/db/src/errors.ts:650](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L650) +Defined in: [packages/db/src/errors.ts:659](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L659) #### Parameters diff --git a/docs/reference/classes/InvalidStorageObjectFormatError.md b/docs/reference/classes/InvalidStorageObjectFormatError.md index c6c41aa81..d2d3cec6e 100644 --- a/docs/reference/classes/InvalidStorageObjectFormatError.md +++ b/docs/reference/classes/InvalidStorageObjectFormatError.md @@ -5,7 +5,7 @@ title: InvalidStorageObjectFormatError # Class: InvalidStorageObjectFormatError -Defined in: [packages/db/src/errors.ts:657](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L657) +Defined in: [packages/db/src/errors.ts:666](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L666) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:657](https://github.com/TanStack/db/blob/ new InvalidStorageObjectFormatError(storageKey): InvalidStorageObjectFormatError; ``` -Defined in: [packages/db/src/errors.ts:658](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L658) +Defined in: [packages/db/src/errors.ts:667](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L667) #### Parameters diff --git a/docs/reference/classes/JoinCollectionNotFoundError.md b/docs/reference/classes/JoinCollectionNotFoundError.md index a2c2440be..1268a7f58 100644 --- a/docs/reference/classes/JoinCollectionNotFoundError.md +++ b/docs/reference/classes/JoinCollectionNotFoundError.md @@ -5,7 +5,7 @@ title: JoinCollectionNotFoundError # Class: JoinCollectionNotFoundError -Defined in: [packages/db/src/errors.ts:521](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L521) +Defined in: [packages/db/src/errors.ts:530](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L530) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:521](https://github.com/TanStack/db/blob/ new JoinCollectionNotFoundError(collectionId): JoinCollectionNotFoundError; ``` -Defined in: [packages/db/src/errors.ts:522](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L522) +Defined in: [packages/db/src/errors.ts:531](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L531) #### Parameters diff --git a/docs/reference/classes/JoinError.md b/docs/reference/classes/JoinError.md index c3522e040..c1154a466 100644 --- a/docs/reference/classes/JoinError.md +++ b/docs/reference/classes/JoinError.md @@ -5,7 +5,7 @@ title: JoinError # Class: JoinError -Defined in: [packages/db/src/errors.ts:528](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L528) +Defined in: [packages/db/src/errors.ts:537](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L537) ## Extends @@ -29,7 +29,7 @@ Defined in: [packages/db/src/errors.ts:528](https://github.com/TanStack/db/blob/ new JoinError(message): JoinError; ``` -Defined in: [packages/db/src/errors.ts:529](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L529) +Defined in: [packages/db/src/errors.ts:538](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L538) #### Parameters diff --git a/docs/reference/classes/LazyIndexWrapper.md b/docs/reference/classes/LazyIndexWrapper.md deleted file mode 100644 index 703809366..000000000 --- a/docs/reference/classes/LazyIndexWrapper.md +++ /dev/null @@ -1,158 +0,0 @@ ---- -id: LazyIndexWrapper -title: LazyIndexWrapper ---- - -# Class: LazyIndexWrapper\ - -Defined in: [packages/db/src/indexes/lazy-index.ts:39](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L39) - -Wrapper that defers index creation until first sync - -## Type Parameters - -### TKey - -`TKey` *extends* `string` \| `number` = `string` \| `number` - -## Constructors - -### Constructor - -```ts -new LazyIndexWrapper( - id, - expression, - name, - resolver, - options, -collectionEntries?): LazyIndexWrapper; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:43](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L43) - -#### Parameters - -##### id - -`number` - -##### expression - -[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md) - -##### name - -`string` | `undefined` - -##### resolver - -[`IndexResolver`](../type-aliases/IndexResolver.md)\<`TKey`\> - -##### options - -`any` - -##### collectionEntries? - -`Iterable`\<\[`TKey`, `any`\], `any`, `any`\> - -#### Returns - -`LazyIndexWrapper`\<`TKey`\> - -## Methods - -### getExpression() - -```ts -getExpression(): BasicExpression; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:118](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L118) - -Get the index expression - -#### Returns - -[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md) - -*** - -### getId() - -```ts -getId(): number; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:104](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L104) - -Get the index ID - -#### Returns - -`number` - -*** - -### getName() - -```ts -getName(): string | undefined; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:111](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L111) - -Get the index name - -#### Returns - -`string` \| `undefined` - -*** - -### getResolved() - -```ts -getResolved(): BaseIndex; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:92](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L92) - -Get resolved index (throws if not ready) - -#### Returns - -[`BaseIndex`](BaseIndex.md)\<`TKey`\> - -*** - -### isResolved() - -```ts -isResolved(): boolean; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:85](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L85) - -Check if already resolved - -#### Returns - -`boolean` - -*** - -### resolve() - -```ts -resolve(): Promise>; -``` - -Defined in: [packages/db/src/indexes/lazy-index.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/lazy-index.ts#L69) - -Resolve the actual index - -#### Returns - -`Promise`\<[`BaseIndex`](BaseIndex.md)\<`TKey`\>\> diff --git a/docs/reference/classes/LimitOffsetRequireOrderByError.md b/docs/reference/classes/LimitOffsetRequireOrderByError.md index f48ee860f..6a41edba3 100644 --- a/docs/reference/classes/LimitOffsetRequireOrderByError.md +++ b/docs/reference/classes/LimitOffsetRequireOrderByError.md @@ -5,7 +5,7 @@ title: LimitOffsetRequireOrderByError # Class: LimitOffsetRequireOrderByError -Defined in: [packages/db/src/errors.ts:453](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L453) +Defined in: [packages/db/src/errors.ts:462](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L462) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:453](https://github.com/TanStack/db/blob/ new LimitOffsetRequireOrderByError(): LimitOffsetRequireOrderByError; ``` -Defined in: [packages/db/src/errors.ts:454](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L454) +Defined in: [packages/db/src/errors.ts:463](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L463) #### Returns diff --git a/docs/reference/classes/LocalStorageCollectionError.md b/docs/reference/classes/LocalStorageCollectionError.md index 0a05c0a7e..78725fca5 100644 --- a/docs/reference/classes/LocalStorageCollectionError.md +++ b/docs/reference/classes/LocalStorageCollectionError.md @@ -5,7 +5,7 @@ title: LocalStorageCollectionError # Class: LocalStorageCollectionError -Defined in: [packages/db/src/errors.ts:636](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L636) +Defined in: [packages/db/src/errors.ts:645](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L645) ## Extends @@ -25,7 +25,7 @@ Defined in: [packages/db/src/errors.ts:636](https://github.com/TanStack/db/blob/ new LocalStorageCollectionError(message): LocalStorageCollectionError; ``` -Defined in: [packages/db/src/errors.ts:637](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L637) +Defined in: [packages/db/src/errors.ts:646](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L646) #### Parameters diff --git a/docs/reference/classes/MissingAliasInputsError.md b/docs/reference/classes/MissingAliasInputsError.md index d0a302b50..8e13aedf0 100644 --- a/docs/reference/classes/MissingAliasInputsError.md +++ b/docs/reference/classes/MissingAliasInputsError.md @@ -5,7 +5,7 @@ title: MissingAliasInputsError # Class: MissingAliasInputsError -Defined in: [packages/db/src/errors.ts:733](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L733) +Defined in: [packages/db/src/errors.ts:742](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L742) Internal error when the compiler returns aliases that don't have corresponding input streams. This should never happen since all aliases come from user declarations. @@ -22,7 +22,7 @@ This should never happen since all aliases come from user declarations. new MissingAliasInputsError(missingAliases): MissingAliasInputsError; ``` -Defined in: [packages/db/src/errors.ts:734](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L734) +Defined in: [packages/db/src/errors.ts:743](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L743) #### Parameters diff --git a/docs/reference/classes/NonAggregateExpressionNotInGroupByError.md b/docs/reference/classes/NonAggregateExpressionNotInGroupByError.md index 293df2191..b34fd7783 100644 --- a/docs/reference/classes/NonAggregateExpressionNotInGroupByError.md +++ b/docs/reference/classes/NonAggregateExpressionNotInGroupByError.md @@ -5,7 +5,7 @@ title: NonAggregateExpressionNotInGroupByError # Class: NonAggregateExpressionNotInGroupByError -Defined in: [packages/db/src/errors.ts:591](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L591) +Defined in: [packages/db/src/errors.ts:600](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L600) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:591](https://github.com/TanStack/db/blob/ new NonAggregateExpressionNotInGroupByError(alias): NonAggregateExpressionNotInGroupByError; ``` -Defined in: [packages/db/src/errors.ts:592](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L592) +Defined in: [packages/db/src/errors.ts:601](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L601) #### Parameters diff --git a/docs/reference/classes/QueryCompilationError.md b/docs/reference/classes/QueryCompilationError.md index 9c63489c9..abd2054de 100644 --- a/docs/reference/classes/QueryCompilationError.md +++ b/docs/reference/classes/QueryCompilationError.md @@ -15,6 +15,7 @@ Defined in: [packages/db/src/errors.ts:423](https://github.com/TanStack/db/blob/ - [`DistinctRequiresSelectError`](DistinctRequiresSelectError.md) - [`FnSelectWithGroupByError`](FnSelectWithGroupByError.md) +- [`UnsupportedRootScalarSelectError`](UnsupportedRootScalarSelectError.md) - [`HavingRequiresGroupByError`](HavingRequiresGroupByError.md) - [`LimitOffsetRequireOrderByError`](LimitOffsetRequireOrderByError.md) - [`CollectionInputNotFoundError`](CollectionInputNotFoundError.md) diff --git a/docs/reference/classes/QueryOptimizerError.md b/docs/reference/classes/QueryOptimizerError.md index 1714c1805..f519315f2 100644 --- a/docs/reference/classes/QueryOptimizerError.md +++ b/docs/reference/classes/QueryOptimizerError.md @@ -5,7 +5,7 @@ title: QueryOptimizerError # Class: QueryOptimizerError -Defined in: [packages/db/src/errors.ts:677](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L677) +Defined in: [packages/db/src/errors.ts:686](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L686) ## Extends @@ -24,7 +24,7 @@ Defined in: [packages/db/src/errors.ts:677](https://github.com/TanStack/db/blob/ new QueryOptimizerError(message): QueryOptimizerError; ``` -Defined in: [packages/db/src/errors.ts:678](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L678) +Defined in: [packages/db/src/errors.ts:687](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L687) #### Parameters diff --git a/docs/reference/classes/ReverseIndex.md b/docs/reference/classes/ReverseIndex.md new file mode 100644 index 000000000..cf4860b02 --- /dev/null +++ b/docs/reference/classes/ReverseIndex.md @@ -0,0 +1,635 @@ +--- +id: ReverseIndex +title: ReverseIndex +--- + +# Class: ReverseIndex\ + +Defined in: [packages/db/src/indexes/reverse-index.ts:6](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L6) + +## Type Parameters + +### TKey + +`TKey` *extends* `string` \| `number` + +## Implements + +- [`IndexInterface`](../interfaces/IndexInterface.md)\<`TKey`\> + +## Constructors + +### Constructor + +```ts +new ReverseIndex(index): ReverseIndex; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:11](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L11) + +#### Parameters + +##### index + +[`IndexInterface`](../interfaces/IndexInterface.md)\<`TKey`\> + +#### Returns + +`ReverseIndex`\<`TKey`\> + +## Accessors + +### indexedKeysSet + +#### Get Signature + +```ts +get indexedKeysSet(): Set; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:124](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L124) + +##### Returns + +`Set`\<`TKey`\> + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`indexedKeysSet`](../interfaces/IndexInterface.md#indexedkeysset) + +*** + +### keyCount + +#### Get Signature + +```ts +get keyCount(): number; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:112](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L112) + +##### Returns + +`number` + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`keyCount`](../interfaces/IndexInterface.md#keycount) + +*** + +### orderedEntriesArray + +#### Get Signature + +```ts +get orderedEntriesArray(): [any, Set][]; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:62](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L62) + +##### Returns + +\[`any`, `Set`\<`TKey`\>\][] + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`orderedEntriesArray`](../interfaces/IndexInterface.md#orderedentriesarray) + +*** + +### orderedEntriesArrayReversed + +#### Get Signature + +```ts +get orderedEntriesArrayReversed(): [any, Set][]; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:66](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L66) + +##### Returns + +\[`any`, `Set`\<`TKey`\>\][] + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`orderedEntriesArrayReversed`](../interfaces/IndexInterface.md#orderedentriesarrayreversed) + +*** + +### valueMapData + +#### Get Signature + +```ts +get valueMapData(): Map>; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:128](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L128) + +##### Returns + +`Map`\<`any`, `Set`\<`TKey`\>\> + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`valueMapData`](../interfaces/IndexInterface.md#valuemapdata) + +## Methods + +### add() + +```ts +add(key, item): void; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:92](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L92) + +#### Parameters + +##### key + +`TKey` + +##### item + +`any` + +#### Returns + +`void` + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`add`](../interfaces/IndexInterface.md#add) + +*** + +### build() + +```ts +build(entries): void; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:104](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L104) + +#### Parameters + +##### entries + +`Iterable`\<\[`TKey`, `any`\]\> + +#### Returns + +`void` + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`build`](../interfaces/IndexInterface.md#build) + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:108](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L108) + +#### Returns + +`void` + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`clear`](../interfaces/IndexInterface.md#clear) + +*** + +### equalityLookup() + +```ts +equalityLookup(value): Set; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:116](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L116) + +#### Parameters + +##### value + +`any` + +#### Returns + +`Set`\<`TKey`\> + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`equalityLookup`](../interfaces/IndexInterface.md#equalitylookup) + +*** + +### getStats() + +```ts +getStats(): IndexStats; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:88](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L88) + +#### Returns + +[`IndexStats`](../interfaces/IndexStats.md) + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`getStats`](../interfaces/IndexInterface.md#getstats) + +*** + +### inArrayLookup() + +```ts +inArrayLookup(values): Set; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:120](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L120) + +#### Parameters + +##### values + +`any`[] + +#### Returns + +`Set`\<`TKey`\> + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`inArrayLookup`](../interfaces/IndexInterface.md#inarraylookup) + +*** + +### lookup() + +```ts +lookup(operation, value): Set; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:17](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L17) + +#### Parameters + +##### operation + +`"eq"` | `"gt"` | `"gte"` | `"lt"` | `"lte"` | `"in"` | `"like"` | `"ilike"` + +##### value + +`any` + +#### Returns + +`Set`\<`TKey`\> + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`lookup`](../interfaces/IndexInterface.md#lookup) + +*** + +### matchesCompareOptions() + +```ts +matchesCompareOptions(compareOptions): boolean; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:80](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L80) + +#### Parameters + +##### compareOptions + +`CompareOptions` + +#### Returns + +`boolean` + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`matchesCompareOptions`](../interfaces/IndexInterface.md#matchescompareoptions) + +*** + +### matchesDirection() + +```ts +matchesDirection(direction): boolean; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:84](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L84) + +#### Parameters + +##### direction + +[`OrderByDirection`](../@tanstack/namespaces/IR/type-aliases/OrderByDirection.md) + +#### Returns + +`boolean` + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`matchesDirection`](../interfaces/IndexInterface.md#matchesdirection) + +*** + +### matchesField() + +```ts +matchesField(fieldPath): boolean; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:76](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L76) + +#### Parameters + +##### fieldPath + +`string`[] + +#### Returns + +`boolean` + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`matchesField`](../interfaces/IndexInterface.md#matchesfield) + +*** + +### rangeQuery() + +```ts +rangeQuery(options): Set; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:31](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L31) + +#### Parameters + +##### options + +[`BTreeRangeQueryOptions`](../interfaces/BTreeRangeQueryOptions.md) = `{}` + +#### Returns + +`Set`\<`TKey`\> + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`rangeQuery`](../interfaces/IndexInterface.md#rangequery) + +*** + +### rangeQueryReversed() + +```ts +rangeQueryReversed(options): Set; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:35](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L35) + +#### Parameters + +##### options + +[`BTreeRangeQueryOptions`](../interfaces/BTreeRangeQueryOptions.md) = `{}` + +#### Returns + +`Set`\<`TKey`\> + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`rangeQueryReversed`](../interfaces/IndexInterface.md#rangequeryreversed) + +*** + +### remove() + +```ts +remove(key, item): void; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:96](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L96) + +#### Parameters + +##### key + +`TKey` + +##### item + +`any` + +#### Returns + +`void` + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`remove`](../interfaces/IndexInterface.md#remove) + +*** + +### supports() + +```ts +supports(operation): boolean; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:72](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L72) + +#### Parameters + +##### operation + +`"eq"` | `"gt"` | `"gte"` | `"lt"` | `"lte"` | `"in"` | `"like"` | `"ilike"` + +#### Returns + +`boolean` + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`supports`](../interfaces/IndexInterface.md#supports) + +*** + +### take() + +```ts +take( + n, + from, + filterFn?): TKey[]; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:39](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L39) + +#### Parameters + +##### n + +`number` + +##### from + +`any` + +##### filterFn? + +(`key`) => `boolean` + +#### Returns + +`TKey`[] + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`take`](../interfaces/IndexInterface.md#take) + +*** + +### takeFromStart() + +```ts +takeFromStart(n, filterFn?): TKey[]; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:43](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L43) + +#### Parameters + +##### n + +`number` + +##### filterFn? + +(`key`) => `boolean` + +#### Returns + +`TKey`[] + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`takeFromStart`](../interfaces/IndexInterface.md#takefromstart) + +*** + +### takeReversed() + +```ts +takeReversed( + n, + from, + filterFn?): TKey[]; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:47](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L47) + +#### Parameters + +##### n + +`number` + +##### from + +`any` + +##### filterFn? + +(`key`) => `boolean` + +#### Returns + +`TKey`[] + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`takeReversed`](../interfaces/IndexInterface.md#takereversed) + +*** + +### takeReversedFromEnd() + +```ts +takeReversedFromEnd(n, filterFn?): TKey[]; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:55](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L55) + +#### Parameters + +##### n + +`number` + +##### filterFn? + +(`key`) => `boolean` + +#### Returns + +`TKey`[] + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`takeReversedFromEnd`](../interfaces/IndexInterface.md#takereversedfromend) + +*** + +### update() + +```ts +update( + key, + oldItem, + newItem): void; +``` + +Defined in: [packages/db/src/indexes/reverse-index.ts:100](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/reverse-index.ts#L100) + +#### Parameters + +##### key + +`TKey` + +##### oldItem + +`any` + +##### newItem + +`any` + +#### Returns + +`void` + +#### Implementation of + +[`IndexInterface`](../interfaces/IndexInterface.md).[`update`](../interfaces/IndexInterface.md#update) diff --git a/docs/reference/classes/SerializationError.md b/docs/reference/classes/SerializationError.md index 1a57d5703..57d07991c 100644 --- a/docs/reference/classes/SerializationError.md +++ b/docs/reference/classes/SerializationError.md @@ -5,7 +5,7 @@ title: SerializationError # Class: SerializationError -Defined in: [packages/db/src/errors.ts:627](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L627) +Defined in: [packages/db/src/errors.ts:636](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L636) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:627](https://github.com/TanStack/db/blob/ new SerializationError(operation, originalError): SerializationError; ``` -Defined in: [packages/db/src/errors.ts:628](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L628) +Defined in: [packages/db/src/errors.ts:637](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L637) #### Parameters diff --git a/docs/reference/classes/SetWindowRequiresOrderByError.md b/docs/reference/classes/SetWindowRequiresOrderByError.md index 0f83fb25c..54e14e7ca 100644 --- a/docs/reference/classes/SetWindowRequiresOrderByError.md +++ b/docs/reference/classes/SetWindowRequiresOrderByError.md @@ -5,7 +5,7 @@ title: SetWindowRequiresOrderByError # Class: SetWindowRequiresOrderByError -Defined in: [packages/db/src/errors.ts:745](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L745) +Defined in: [packages/db/src/errors.ts:754](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L754) Error thrown when setWindow is called on a collection without an ORDER BY clause. @@ -21,7 +21,7 @@ Error thrown when setWindow is called on a collection without an ORDER BY clause new SetWindowRequiresOrderByError(): SetWindowRequiresOrderByError; ``` -Defined in: [packages/db/src/errors.ts:746](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L746) +Defined in: [packages/db/src/errors.ts:755](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L755) #### Returns diff --git a/docs/reference/classes/StorageError.md b/docs/reference/classes/StorageError.md index 681556716..503edc084 100644 --- a/docs/reference/classes/StorageError.md +++ b/docs/reference/classes/StorageError.md @@ -5,7 +5,7 @@ title: StorageError # Class: StorageError -Defined in: [packages/db/src/errors.ts:620](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L620) +Defined in: [packages/db/src/errors.ts:629](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L629) ## Extends @@ -24,7 +24,7 @@ Defined in: [packages/db/src/errors.ts:620](https://github.com/TanStack/db/blob/ new StorageError(message): StorageError; ``` -Defined in: [packages/db/src/errors.ts:621](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L621) +Defined in: [packages/db/src/errors.ts:630](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L630) #### Parameters diff --git a/docs/reference/classes/StorageKeyRequiredError.md b/docs/reference/classes/StorageKeyRequiredError.md index 9e61351cf..43c7b92c1 100644 --- a/docs/reference/classes/StorageKeyRequiredError.md +++ b/docs/reference/classes/StorageKeyRequiredError.md @@ -5,7 +5,7 @@ title: StorageKeyRequiredError # Class: StorageKeyRequiredError -Defined in: [packages/db/src/errors.ts:643](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L643) +Defined in: [packages/db/src/errors.ts:652](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L652) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:643](https://github.com/TanStack/db/blob/ new StorageKeyRequiredError(): StorageKeyRequiredError; ``` -Defined in: [packages/db/src/errors.ts:644](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L644) +Defined in: [packages/db/src/errors.ts:653](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L653) #### Returns diff --git a/docs/reference/classes/SubscriptionNotFoundError.md b/docs/reference/classes/SubscriptionNotFoundError.md index d357eaa67..29f745156 100644 --- a/docs/reference/classes/SubscriptionNotFoundError.md +++ b/docs/reference/classes/SubscriptionNotFoundError.md @@ -5,7 +5,7 @@ title: SubscriptionNotFoundError # Class: SubscriptionNotFoundError -Defined in: [packages/db/src/errors.ts:705](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L705) +Defined in: [packages/db/src/errors.ts:714](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L714) Error when a subscription cannot be found during lazy join processing. For subqueries, aliases may be remapped (e.g., 'activeUser' → 'user'). @@ -26,7 +26,7 @@ new SubscriptionNotFoundError( availableAliases): SubscriptionNotFoundError; ``` -Defined in: [packages/db/src/errors.ts:706](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L706) +Defined in: [packages/db/src/errors.ts:715](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L715) #### Parameters diff --git a/docs/reference/classes/SyncCleanupError.md b/docs/reference/classes/SyncCleanupError.md index 79b55156f..f36d0e1d4 100644 --- a/docs/reference/classes/SyncCleanupError.md +++ b/docs/reference/classes/SyncCleanupError.md @@ -5,7 +5,7 @@ title: SyncCleanupError # Class: SyncCleanupError -Defined in: [packages/db/src/errors.ts:666](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L666) +Defined in: [packages/db/src/errors.ts:675](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L675) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:666](https://github.com/TanStack/db/blob/ new SyncCleanupError(collectionId, error): SyncCleanupError; ``` -Defined in: [packages/db/src/errors.ts:667](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L667) +Defined in: [packages/db/src/errors.ts:676](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L676) #### Parameters diff --git a/docs/reference/classes/UnknownExpressionTypeError.md b/docs/reference/classes/UnknownExpressionTypeError.md index c5ca089d3..0aadc0abb 100644 --- a/docs/reference/classes/UnknownExpressionTypeError.md +++ b/docs/reference/classes/UnknownExpressionTypeError.md @@ -5,7 +5,7 @@ title: UnknownExpressionTypeError # Class: UnknownExpressionTypeError -Defined in: [packages/db/src/errors.ts:503](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L503) +Defined in: [packages/db/src/errors.ts:512](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L512) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:503](https://github.com/TanStack/db/blob/ new UnknownExpressionTypeError(type): UnknownExpressionTypeError; ``` -Defined in: [packages/db/src/errors.ts:504](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L504) +Defined in: [packages/db/src/errors.ts:513](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L513) #### Parameters diff --git a/docs/reference/classes/UnknownFunctionError.md b/docs/reference/classes/UnknownFunctionError.md index d3dd6434c..fda586a8f 100644 --- a/docs/reference/classes/UnknownFunctionError.md +++ b/docs/reference/classes/UnknownFunctionError.md @@ -5,7 +5,7 @@ title: UnknownFunctionError # Class: UnknownFunctionError -Defined in: [packages/db/src/errors.ts:515](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L515) +Defined in: [packages/db/src/errors.ts:524](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L524) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:515](https://github.com/TanStack/db/blob/ new UnknownFunctionError(functionName): UnknownFunctionError; ``` -Defined in: [packages/db/src/errors.ts:516](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L516) +Defined in: [packages/db/src/errors.ts:525](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L525) #### Parameters diff --git a/docs/reference/classes/UnknownHavingExpressionTypeError.md b/docs/reference/classes/UnknownHavingExpressionTypeError.md index d9acff77d..6f4806558 100644 --- a/docs/reference/classes/UnknownHavingExpressionTypeError.md +++ b/docs/reference/classes/UnknownHavingExpressionTypeError.md @@ -5,7 +5,7 @@ title: UnknownHavingExpressionTypeError # Class: UnknownHavingExpressionTypeError -Defined in: [packages/db/src/errors.ts:613](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L613) +Defined in: [packages/db/src/errors.ts:622](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L622) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:613](https://github.com/TanStack/db/blob/ new UnknownHavingExpressionTypeError(type): UnknownHavingExpressionTypeError; ``` -Defined in: [packages/db/src/errors.ts:614](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L614) +Defined in: [packages/db/src/errors.ts:623](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L623) #### Parameters diff --git a/docs/reference/classes/UnsupportedAggregateFunctionError.md b/docs/reference/classes/UnsupportedAggregateFunctionError.md index 177cf0c5e..b2eaefe29 100644 --- a/docs/reference/classes/UnsupportedAggregateFunctionError.md +++ b/docs/reference/classes/UnsupportedAggregateFunctionError.md @@ -5,7 +5,7 @@ title: UnsupportedAggregateFunctionError # Class: UnsupportedAggregateFunctionError -Defined in: [packages/db/src/errors.ts:599](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L599) +Defined in: [packages/db/src/errors.ts:608](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L608) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:599](https://github.com/TanStack/db/blob/ new UnsupportedAggregateFunctionError(functionName): UnsupportedAggregateFunctionError; ``` -Defined in: [packages/db/src/errors.ts:600](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L600) +Defined in: [packages/db/src/errors.ts:609](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L609) #### Parameters diff --git a/docs/reference/classes/UnsupportedFromTypeError.md b/docs/reference/classes/UnsupportedFromTypeError.md index 7c269473e..a2a98b89d 100644 --- a/docs/reference/classes/UnsupportedFromTypeError.md +++ b/docs/reference/classes/UnsupportedFromTypeError.md @@ -5,7 +5,7 @@ title: UnsupportedFromTypeError # Class: UnsupportedFromTypeError -Defined in: [packages/db/src/errors.ts:497](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L497) +Defined in: [packages/db/src/errors.ts:506](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L506) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:497](https://github.com/TanStack/db/blob/ new UnsupportedFromTypeError(type): UnsupportedFromTypeError; ``` -Defined in: [packages/db/src/errors.ts:498](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L498) +Defined in: [packages/db/src/errors.ts:507](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L507) #### Parameters diff --git a/docs/reference/classes/UnsupportedJoinSourceTypeError.md b/docs/reference/classes/UnsupportedJoinSourceTypeError.md index 0835ae9df..f355eee52 100644 --- a/docs/reference/classes/UnsupportedJoinSourceTypeError.md +++ b/docs/reference/classes/UnsupportedJoinSourceTypeError.md @@ -5,7 +5,7 @@ title: UnsupportedJoinSourceTypeError # Class: UnsupportedJoinSourceTypeError -Defined in: [packages/db/src/errors.ts:577](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L577) +Defined in: [packages/db/src/errors.ts:586](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L586) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:577](https://github.com/TanStack/db/blob/ new UnsupportedJoinSourceTypeError(type): UnsupportedJoinSourceTypeError; ``` -Defined in: [packages/db/src/errors.ts:578](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L578) +Defined in: [packages/db/src/errors.ts:587](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L587) #### Parameters diff --git a/docs/reference/classes/UnsupportedJoinTypeError.md b/docs/reference/classes/UnsupportedJoinTypeError.md index a5e480bfe..23ba03b1b 100644 --- a/docs/reference/classes/UnsupportedJoinTypeError.md +++ b/docs/reference/classes/UnsupportedJoinTypeError.md @@ -5,7 +5,7 @@ title: UnsupportedJoinTypeError # Class: UnsupportedJoinTypeError -Defined in: [packages/db/src/errors.ts:535](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L535) +Defined in: [packages/db/src/errors.ts:544](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L544) ## Extends @@ -19,7 +19,7 @@ Defined in: [packages/db/src/errors.ts:535](https://github.com/TanStack/db/blob/ new UnsupportedJoinTypeError(joinType): UnsupportedJoinTypeError; ``` -Defined in: [packages/db/src/errors.ts:536](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L536) +Defined in: [packages/db/src/errors.ts:545](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L545) #### Parameters diff --git a/docs/reference/classes/UnsupportedRootScalarSelectError.md b/docs/reference/classes/UnsupportedRootScalarSelectError.md new file mode 100644 index 000000000..a3996fdf1 --- /dev/null +++ b/docs/reference/classes/UnsupportedRootScalarSelectError.md @@ -0,0 +1,214 @@ +--- +id: UnsupportedRootScalarSelectError +title: UnsupportedRootScalarSelectError +--- + +# Class: UnsupportedRootScalarSelectError + +Defined in: [packages/db/src/errors.ts:447](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L447) + +## Extends + +- [`QueryCompilationError`](QueryCompilationError.md) + +## Constructors + +### Constructor + +```ts +new UnsupportedRootScalarSelectError(): UnsupportedRootScalarSelectError; +``` + +Defined in: [packages/db/src/errors.ts:448](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L448) + +#### Returns + +`UnsupportedRootScalarSelectError` + +#### Overrides + +[`QueryCompilationError`](QueryCompilationError.md).[`constructor`](QueryCompilationError.md#constructor) + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 + +#### Inherited from + +[`QueryCompilationError`](QueryCompilationError.md).[`cause`](QueryCompilationError.md#cause) + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 + +#### Inherited from + +[`QueryCompilationError`](QueryCompilationError.md).[`message`](QueryCompilationError.md#message) + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +[`QueryCompilationError`](QueryCompilationError.md).[`name`](QueryCompilationError.md#name) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 + +#### Inherited from + +[`QueryCompilationError`](QueryCompilationError.md).[`stack`](QueryCompilationError.md#stack) + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:67 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +[`QueryCompilationError`](QueryCompilationError.md).[`stackTraceLimit`](QueryCompilationError.md#stacktracelimit) + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:51 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +[`QueryCompilationError`](QueryCompilationError.md).[`captureStackTrace`](QueryCompilationError.md#capturestacktrace) + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:55 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +[`QueryCompilationError`](QueryCompilationError.md).[`prepareStackTrace`](QueryCompilationError.md#preparestacktrace) diff --git a/docs/reference/classes/WhereClauseConversionError.md b/docs/reference/classes/WhereClauseConversionError.md index c26bcdce7..21d94f459 100644 --- a/docs/reference/classes/WhereClauseConversionError.md +++ b/docs/reference/classes/WhereClauseConversionError.md @@ -5,7 +5,7 @@ title: WhereClauseConversionError # Class: WhereClauseConversionError -Defined in: [packages/db/src/errors.ts:693](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L693) +Defined in: [packages/db/src/errors.ts:702](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L702) Internal error when the query optimizer fails to convert a WHERE clause to a collection filter. @@ -21,7 +21,7 @@ Internal error when the query optimizer fails to convert a WHERE clause to a col new WhereClauseConversionError(collectionId, alias): WhereClauseConversionError; ``` -Defined in: [packages/db/src/errors.ts:694](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L694) +Defined in: [packages/db/src/errors.ts:703](https://github.com/TanStack/db/blob/main/packages/db/src/errors.ts#L703) #### Parameters diff --git a/docs/reference/electric-db-collection/functions/electricCollectionOptions.md b/docs/reference/electric-db-collection/functions/electricCollectionOptions.md index ff7eb715f..8a057e80a 100644 --- a/docs/reference/electric-db-collection/functions/electricCollectionOptions.md +++ b/docs/reference/electric-db-collection/functions/electricCollectionOptions.md @@ -11,7 +11,7 @@ title: electricCollectionOptions function electricCollectionOptions(config): Omit, string | number, T, UtilsRecord>, "utils" | "onInsert" | "onUpdate" | "onDelete"> & Pick, T>, "onInsert" | "onUpdate" | "onDelete"> & object; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:529](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L529) +Defined in: [packages/electric-db-collection/src/electric.ts:570](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L570) Creates Electric collection options for use with a standard Collection @@ -43,7 +43,7 @@ Collection options with utilities function electricCollectionOptions(config): Omit, "utils" | "onInsert" | "onUpdate" | "onDelete"> & Pick, "onInsert" | "onUpdate" | "onDelete"> & object; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:547](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L547) +Defined in: [packages/electric-db-collection/src/electric.ts:588](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L588) Creates Electric collection options for use with a standard Collection diff --git a/docs/reference/electric-db-collection/functions/isChangeMessage.md b/docs/reference/electric-db-collection/functions/isChangeMessage.md index c1fd0f6d5..4e8341df1 100644 --- a/docs/reference/electric-db-collection/functions/isChangeMessage.md +++ b/docs/reference/electric-db-collection/functions/isChangeMessage.md @@ -9,7 +9,7 @@ title: isChangeMessage function isChangeMessage(message): message is ChangeMessage; ``` -Defined in: node\_modules/.pnpm/@electric-sql+client@1.5.12/node\_modules/@electric-sql/client/dist/index.d.ts:886 +Defined in: node\_modules/.pnpm/@electric-sql+client@1.5.13/node\_modules/@electric-sql/client/dist/index.d.ts:886 Type guard for checking Message is ChangeMessage. diff --git a/docs/reference/electric-db-collection/functions/isControlMessage.md b/docs/reference/electric-db-collection/functions/isControlMessage.md index ef035985b..3b9afdb3c 100644 --- a/docs/reference/electric-db-collection/functions/isControlMessage.md +++ b/docs/reference/electric-db-collection/functions/isControlMessage.md @@ -9,7 +9,7 @@ title: isControlMessage function isControlMessage(message): message is ControlMessage; ``` -Defined in: node\_modules/.pnpm/@electric-sql+client@1.5.12/node\_modules/@electric-sql/client/dist/index.d.ts:904 +Defined in: node\_modules/.pnpm/@electric-sql+client@1.5.13/node\_modules/@electric-sql/client/dist/index.d.ts:904 Type guard for checking Message is ControlMessage. diff --git a/docs/reference/electric-db-collection/interfaces/ElectricCollectionConfig.md b/docs/reference/electric-db-collection/interfaces/ElectricCollectionConfig.md index dfa78a9d0..aed092210 100644 --- a/docs/reference/electric-db-collection/interfaces/ElectricCollectionConfig.md +++ b/docs/reference/electric-db-collection/interfaces/ElectricCollectionConfig.md @@ -5,7 +5,7 @@ title: ElectricCollectionConfig # Interface: ElectricCollectionConfig\ -Defined in: [packages/electric-db-collection/src/electric.ts:141](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L141) +Defined in: [packages/electric-db-collection/src/electric.ts:142](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L142) Configuration interface for Electric collection options @@ -35,7 +35,7 @@ The schema type for validation optional [ELECTRIC_TEST_HOOKS]: ElectricTestHooks; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:164](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L164) +Defined in: [packages/electric-db-collection/src/electric.ts:165](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L165) Internal test hooks (for testing only) Hidden via Symbol to prevent accidental usage in production @@ -48,7 +48,7 @@ Hidden via Symbol to prevent accidental usage in production optional onDelete: (params) => Promise; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:281](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L281) +Defined in: [packages/electric-db-collection/src/electric.ts:282](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L282) Optional asynchronous handler function called before a delete operation @@ -100,7 +100,7 @@ onDelete: async ({ transaction, collection }) => { optional onInsert: (params) => Promise; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:212](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L212) +Defined in: [packages/electric-db-collection/src/electric.ts:213](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L213) Optional asynchronous handler function called before an insert operation @@ -174,7 +174,7 @@ onInsert: async ({ transaction, collection }) => { optional onUpdate: (params) => Promise; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:247](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L247) +Defined in: [packages/electric-db-collection/src/electric.ts:248](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L248) Optional asynchronous handler function called before an update operation @@ -227,7 +227,7 @@ onUpdate: async ({ transaction, collection }) => { shapeOptions: ShapeStreamOptions>; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:157](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L157) +Defined in: [packages/electric-db-collection/src/electric.ts:158](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L158) Configuration options for the ElectricSQL ShapeStream @@ -239,4 +239,4 @@ Configuration options for the ElectricSQL ShapeStream optional syncMode: ElectricSyncMode; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:158](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L158) +Defined in: [packages/electric-db-collection/src/electric.ts:159](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L159) diff --git a/docs/reference/electric-db-collection/interfaces/ElectricCollectionUtils.md b/docs/reference/electric-db-collection/interfaces/ElectricCollectionUtils.md index f91cbe8da..f359a7787 100644 --- a/docs/reference/electric-db-collection/interfaces/ElectricCollectionUtils.md +++ b/docs/reference/electric-db-collection/interfaces/ElectricCollectionUtils.md @@ -5,7 +5,7 @@ title: ElectricCollectionUtils # Interface: ElectricCollectionUtils\ -Defined in: [packages/electric-db-collection/src/electric.ts:511](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L511) +Defined in: [packages/electric-db-collection/src/electric.ts:552](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L552) Electric collection utilities type @@ -33,7 +33,7 @@ Electric collection utilities type awaitMatch: AwaitMatchFn; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:515](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L515) +Defined in: [packages/electric-db-collection/src/electric.ts:556](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L556) *** @@ -43,4 +43,4 @@ Defined in: [packages/electric-db-collection/src/electric.ts:515](https://github awaitTxId: AwaitTxIdFn; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:514](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L514) +Defined in: [packages/electric-db-collection/src/electric.ts:555](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L555) diff --git a/docs/reference/electric-db-collection/type-aliases/AwaitTxIdFn.md b/docs/reference/electric-db-collection/type-aliases/AwaitTxIdFn.md index a5ebc225d..139c6dfda 100644 --- a/docs/reference/electric-db-collection/type-aliases/AwaitTxIdFn.md +++ b/docs/reference/electric-db-collection/type-aliases/AwaitTxIdFn.md @@ -9,7 +9,7 @@ title: AwaitTxIdFn type AwaitTxIdFn = (txId, timeout?) => Promise; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:498](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L498) +Defined in: [packages/electric-db-collection/src/electric.ts:539](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L539) Type for the awaitTxId utility function diff --git a/docs/reference/electric-db-collection/type-aliases/Txid.md b/docs/reference/electric-db-collection/type-aliases/Txid.md index 2133770f8..e875e3db8 100644 --- a/docs/reference/electric-db-collection/type-aliases/Txid.md +++ b/docs/reference/electric-db-collection/type-aliases/Txid.md @@ -9,6 +9,6 @@ title: Txid type Txid = number; ``` -Defined in: [packages/electric-db-collection/src/electric.ts:79](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L79) +Defined in: [packages/electric-db-collection/src/electric.ts:80](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L80) Type representing a transaction ID in ElectricSQL diff --git a/docs/reference/functions/add.md b/docs/reference/functions/add.md index 767e7d8d1..1c3ceb924 100644 --- a/docs/reference/functions/add.md +++ b/docs/reference/functions/add.md @@ -9,17 +9,17 @@ title: add function add(left, right): BinaryNumericReturnType; ``` -Defined in: [packages/db/src/query/builder/functions.ts:295](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L295) +Defined in: [packages/db/src/query/builder/functions.ts:354](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L354) ## Type Parameters ### T1 -`T1` *extends* `unknown` +`T1` *extends* `ExpressionLike` ### T2 -`T2` *extends* `unknown` +`T2` *extends* `ExpressionLike` ## Parameters diff --git a/docs/reference/functions/and.md b/docs/reference/functions/and.md index 85a7304a1..b99e1c232 100644 --- a/docs/reference/functions/and.md +++ b/docs/reference/functions/and.md @@ -11,17 +11,17 @@ title: and function and(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:181](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L181) +Defined in: [packages/db/src/query/builder/functions.ts:199](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L199) ### Parameters #### left -`any` +`ExpressionLike` #### right -`any` +`ExpressionLike` ### Returns @@ -36,21 +36,21 @@ function and( rest): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:185](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L185) +Defined in: [packages/db/src/query/builder/functions.ts:203](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L203) ### Parameters #### left -`any` +`ExpressionLike` #### right -`any` +`ExpressionLike` #### rest -...`any`[] +...`ExpressionLike`[] ### Returns diff --git a/docs/reference/functions/avg.md b/docs/reference/functions/avg.md index 98b7f615a..acf474d67 100644 --- a/docs/reference/functions/avg.md +++ b/docs/reference/functions/avg.md @@ -9,13 +9,13 @@ title: avg function avg(arg): AggregateReturnType; ``` -Defined in: [packages/db/src/query/builder/functions.ts:311](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L311) +Defined in: [packages/db/src/query/builder/functions.ts:370](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L370) ## Type Parameters ### T -`T` *extends* `unknown` +`T` *extends* `ExpressionLike` ## Parameters diff --git a/docs/reference/functions/clearQueryPatterns.md b/docs/reference/functions/clearQueryPatterns.md new file mode 100644 index 000000000..6c56bbb5e --- /dev/null +++ b/docs/reference/functions/clearQueryPatterns.md @@ -0,0 +1,18 @@ +--- +id: clearQueryPatterns +title: clearQueryPatterns +--- + +# Function: clearQueryPatterns() + +```ts +function clearQueryPatterns(): void; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:157](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L157) + +Clear query pattern tracking (useful for tests) + +## Returns + +`void` diff --git a/docs/reference/functions/coalesce.md b/docs/reference/functions/coalesce.md index 2849b63e8..d78f0bbc8 100644 --- a/docs/reference/functions/coalesce.md +++ b/docs/reference/functions/coalesce.md @@ -6,17 +6,23 @@ title: coalesce # Function: coalesce() ```ts -function coalesce(...args): BasicExpression; +function coalesce(...args): CoalesceReturnType; ``` -Defined in: [packages/db/src/query/builder/functions.ts:288](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L288) +Defined in: [packages/db/src/query/builder/functions.ts:345](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L345) + +## Type Parameters + +### T + +`T` *extends* \[`ExpressionLike`, `...ExpressionLike[]`\] ## Parameters ### args -...`any`[] +...`T` ## Returns -[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md)\<`any`\> +`CoalesceReturnType`\<`T`\> diff --git a/docs/reference/functions/compileExpression.md b/docs/reference/functions/compileExpression.md new file mode 100644 index 000000000..1908f7522 --- /dev/null +++ b/docs/reference/functions/compileExpression.md @@ -0,0 +1,29 @@ +--- +id: compileExpression +title: compileExpression +--- + +# Function: compileExpression() + +```ts +function compileExpression(expr, isSingleRow): CompiledSingleRowExpression | CompiledExpression; +``` + +Defined in: [packages/db/src/query/compiler/evaluators.ts:72](https://github.com/TanStack/db/blob/main/packages/db/src/query/compiler/evaluators.ts#L72) + +Compiles an expression into an optimized evaluator function. +This eliminates branching during evaluation by pre-compiling the expression structure. + +## Parameters + +### expr + +[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md) + +### isSingleRow + +`boolean` = `false` + +## Returns + +`CompiledSingleRowExpression` \| `CompiledExpression` diff --git a/docs/reference/functions/compileQuery.md b/docs/reference/functions/compileQuery.md index 80941c0c1..4f6db2f57 100644 --- a/docs/reference/functions/compileQuery.md +++ b/docs/reference/functions/compileQuery.md @@ -16,10 +16,12 @@ function compileQuery( optimizableOrderByCollections, setWindowFn, cache, - queryMapping): CompilationResult; + queryMapping, + parentKeyStream?, + childCorrelationField?): CompilationResult; ``` -Defined in: [packages/db/src/query/compiler/index.ts:86](https://github.com/TanStack/db/blob/main/packages/db/src/query/compiler/index.ts#L86) +Defined in: [packages/db/src/query/compiler/index.ts:130](https://github.com/TanStack/db/blob/main/packages/db/src/query/compiler/index.ts#L130) Compiles a query IR into a D2 pipeline @@ -83,6 +85,14 @@ Optional cache for compiled subqueries (used internally for recursion) Optional mapping from optimized queries to original queries +### parentKeyStream? + +[`KeyedStream`](../type-aliases/KeyedStream.md) + +### childCorrelationField? + +[`PropRef`](../@tanstack/namespaces/IR/classes/PropRef.md)\<`any`\> + ## Returns `CompilationResult` diff --git a/docs/reference/functions/compileSingleRowExpression.md b/docs/reference/functions/compileSingleRowExpression.md new file mode 100644 index 000000000..19ab88aa2 --- /dev/null +++ b/docs/reference/functions/compileSingleRowExpression.md @@ -0,0 +1,24 @@ +--- +id: compileSingleRowExpression +title: compileSingleRowExpression +--- + +# Function: compileSingleRowExpression() + +```ts +function compileSingleRowExpression(expr): CompiledSingleRowExpression; +``` + +Defined in: [packages/db/src/query/compiler/evaluators.ts:83](https://github.com/TanStack/db/blob/main/packages/db/src/query/compiler/evaluators.ts#L83) + +Compiles a single-row expression into an optimized evaluator function. + +## Parameters + +### expr + +[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md) + +## Returns + +`CompiledSingleRowExpression` diff --git a/docs/reference/functions/concat.md b/docs/reference/functions/concat.md index 1da806bc5..ddfaf560e 100644 --- a/docs/reference/functions/concat.md +++ b/docs/reference/functions/concat.md @@ -5,18 +5,44 @@ title: concat # Function: concat() +## Call Signature + +```ts +function concat(arg): ConcatToArrayWrapper; +``` + +Defined in: [packages/db/src/query/builder/functions.ts:297](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L297) + +### Type Parameters + +#### T + +`T` *extends* `StringifiableScalar` + +### Parameters + +#### arg + +`ToArrayWrapper`\<`T`\> + +### Returns + +`ConcatToArrayWrapper`\<`T`\> + +## Call Signature + ```ts function concat(...args): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:279](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L279) +Defined in: [packages/db/src/query/builder/functions.ts:300](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L300) -## Parameters +### Parameters -### args +#### args -...`any`[] +...`ExpressionLike`[] -## Returns +### Returns [`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md)\<`string`\> diff --git a/docs/reference/functions/configureIndexDevMode.md b/docs/reference/functions/configureIndexDevMode.md new file mode 100644 index 000000000..2c3004051 --- /dev/null +++ b/docs/reference/functions/configureIndexDevMode.md @@ -0,0 +1,24 @@ +--- +id: configureIndexDevMode +title: configureIndexDevMode +--- + +# Function: configureIndexDevMode() + +```ts +function configureIndexDevMode(config): void; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:50](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L50) + +Configure dev mode for index suggestions + +## Parameters + +### config + +`Partial`\<[`IndexDevModeConfig`](../interfaces/IndexDevModeConfig.md)\> + +## Returns + +`void` diff --git a/docs/reference/functions/count.md b/docs/reference/functions/count.md index ef1a990e9..c1a8436e9 100644 --- a/docs/reference/functions/count.md +++ b/docs/reference/functions/count.md @@ -9,13 +9,13 @@ title: count function count(arg): Aggregate; ``` -Defined in: [packages/db/src/query/builder/functions.ts:307](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L307) +Defined in: [packages/db/src/query/builder/functions.ts:366](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L366) ## Parameters ### arg -`any` +`ExpressionLike` ## Returns diff --git a/docs/reference/functions/createCollection.md b/docs/reference/functions/createCollection.md index 556471744..c36372d47 100644 --- a/docs/reference/functions/createCollection.md +++ b/docs/reference/functions/createCollection.md @@ -11,7 +11,7 @@ title: createCollection function createCollection(options): Collection, TKey, TUtils, T, InferSchemaInput> & NonSingleResult; ``` -Defined in: [packages/db/src/collection/index.ts:134](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L134) +Defined in: [packages/db/src/collection/index.ts:140](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L140) Creates a new Collection instance with the given configuration @@ -120,7 +120,7 @@ const todos = createCollection({ function createCollection(options): Collection, TKey, Exclude, T, InferSchemaInput> & NonSingleResult; ``` -Defined in: [packages/db/src/collection/index.ts:151](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L151) +Defined in: [packages/db/src/collection/index.ts:157](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L157) Creates a new Collection instance with the given configuration @@ -229,7 +229,7 @@ const todos = createCollection({ function createCollection(options): Collection, TKey, TUtils, T, InferSchemaInput> & SingleResult; ``` -Defined in: [packages/db/src/collection/index.ts:169](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L169) +Defined in: [packages/db/src/collection/index.ts:175](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L175) Creates a new Collection instance with the given configuration @@ -338,7 +338,7 @@ const todos = createCollection({ function createCollection(options): Collection, TKey, TUtils, T, InferSchemaInput> & SingleResult; ``` -Defined in: [packages/db/src/collection/index.ts:185](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L185) +Defined in: [packages/db/src/collection/index.ts:191](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L191) Creates a new Collection instance with the given configuration @@ -447,7 +447,7 @@ const todos = createCollection({ function createCollection(options): Collection & NonSingleResult; ``` -Defined in: [packages/db/src/collection/index.ts:198](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L198) +Defined in: [packages/db/src/collection/index.ts:204](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L204) Creates a new Collection instance with the given configuration @@ -556,7 +556,7 @@ const todos = createCollection({ function createCollection(options): Collection & NonSingleResult; ``` -Defined in: [packages/db/src/collection/index.ts:211](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L211) +Defined in: [packages/db/src/collection/index.ts:217](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L217) Creates a new Collection instance with the given configuration @@ -665,7 +665,7 @@ const todos = createCollection({ function createCollection(options): Collection & SingleResult; ``` -Defined in: [packages/db/src/collection/index.ts:223](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L223) +Defined in: [packages/db/src/collection/index.ts:229](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L229) Creates a new Collection instance with the given configuration @@ -774,7 +774,7 @@ const todos = createCollection({ function createCollection(options): Collection & SingleResult; ``` -Defined in: [packages/db/src/collection/index.ts:236](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L236) +Defined in: [packages/db/src/collection/index.ts:242](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L242) Creates a new Collection instance with the given configuration diff --git a/docs/reference/functions/createEffect.md b/docs/reference/functions/createEffect.md new file mode 100644 index 000000000..8ab2ead62 --- /dev/null +++ b/docs/reference/functions/createEffect.md @@ -0,0 +1,51 @@ +--- +id: createEffect +title: createEffect +--- + +# Function: createEffect() + +```ts +function createEffect(config): Effect; +``` + +Defined in: [packages/db/src/query/effect.ts:184](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L184) + +Creates a reactive effect that fires handlers when rows enter, exit, or +update within a query result. Effects process deltas only — they do not +maintain or require the full materialised query result. + +## Type Parameters + +### TRow + +`TRow` *extends* `object` = `Record`\<`string`, `unknown`\> + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + +## Parameters + +### config + +[`EffectConfig`](../interfaces/EffectConfig.md)\<`TRow`, `TKey`\> + +## Returns + +[`Effect`](../interfaces/Effect.md) + +## Example + +```typescript +const effect = createEffect({ + query: (q) => q.from({ msg: messagesCollection }) + .where(({ msg }) => eq(msg.role, 'user')), + onEnter: async (event) => { + await generateResponse(event.value) + }, +}) + +// Later: stop the effect +await effect.dispose() +``` diff --git a/docs/reference/functions/createLiveQueryCollection.md b/docs/reference/functions/createLiveQueryCollection.md index 55db713f5..d6968781d 100644 --- a/docs/reference/functions/createLiveQueryCollection.md +++ b/docs/reference/functions/createLiveQueryCollection.md @@ -8,33 +8,33 @@ title: createLiveQueryCollection ## Call Signature ```ts -function createLiveQueryCollection(query): CollectionForContext(query): CollectionForContext, RootQueryResult>, { }> & object; ``` -Defined in: [packages/db/src/query/live-query-collection.ts:115](https://github.com/TanStack/db/blob/main/packages/db/src/query/live-query-collection.ts#L115) +Defined in: [packages/db/src/query/live-query-collection.ts:128](https://github.com/TanStack/db/blob/main/packages/db/src/query/live-query-collection.ts#L128) Creates a live query collection directly ### Type Parameters -#### TContext +#### TQueryFn -`TContext` *extends* [`Context`](../interfaces/Context.md) +`TQueryFn` *extends* (`q`) => [`QueryBuilder`](../type-aliases/QueryBuilder.md)\<`any`\> -#### TResult +#### TQuery -`TResult` *extends* `object` = \{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \} +`TQuery` *extends* [`QueryBuilder`](../type-aliases/QueryBuilder.md)\<`any`\> = `ReturnType`\<`TQueryFn`\> ### Parameters #### query -(`q`) => [`QueryBuilder`](../type-aliases/QueryBuilder.md)\<`TContext`\> +`TQueryFn` & `RootQueryFn`\<`TQuery`\> ### Returns -`CollectionForContext`\<`TContext`, `TResult`, \{ +`CollectionForContext`\<[`ExtractContext`](../type-aliases/ExtractContext.md)\<`TQuery`\>, `RootQueryResult`\<[`ExtractContext`](../type-aliases/ExtractContext.md)\<`TQuery`\>\>, \{ \}\> & `object` ### Example @@ -71,23 +71,23 @@ const searchResults = createLiveQueryCollection({ ## Call Signature ```ts -function createLiveQueryCollection(config): CollectionForContext(config): CollectionForContext, { }> & object; ``` -Defined in: [packages/db/src/query/live-query-collection.ts:125](https://github.com/TanStack/db/blob/main/packages/db/src/query/live-query-collection.ts#L125) +Defined in: [packages/db/src/query/live-query-collection.ts:141](https://github.com/TanStack/db/blob/main/packages/db/src/query/live-query-collection.ts#L141) Creates a live query collection directly ### Type Parameters -#### TContext +#### TQuery -`TContext` *extends* [`Context`](../interfaces/Context.md) +`TQuery` *extends* [`QueryBuilder`](../type-aliases/QueryBuilder.md)\<`any`\> -#### TResult +#### TContext -`TResult` *extends* `object` = \{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \} +`TContext` *extends* [`Context`](../interfaces/Context.md) = [`ExtractContext`](../type-aliases/ExtractContext.md)\<`TQuery`\> #### TUtils @@ -98,11 +98,11 @@ Creates a live query collection directly #### config -[`LiveQueryCollectionConfig`](../interfaces/LiveQueryCollectionConfig.md)\<`TContext`, `TResult`\> & `object` +[`LiveQueryCollectionConfig`](../interfaces/LiveQueryCollectionConfig.md)\<`TContext`, `RootQueryResult`\<`TContext`\>\> & `object` ### Returns -`CollectionForContext`\<`TContext`, `TResult`, \{ +`CollectionForContext`\<`TContext`, `RootQueryResult`\<`TContext`\>, \{ \}\> & `object` ### Example diff --git a/docs/reference/functions/eq.md b/docs/reference/functions/eq.md index 8890c3eac..794ec946c 100644 --- a/docs/reference/functions/eq.md +++ b/docs/reference/functions/eq.md @@ -11,7 +11,7 @@ title: eq function eq(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:115](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L115) +Defined in: [packages/db/src/query/builder/functions.ts:133](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L133) ### Type Parameters @@ -39,7 +39,7 @@ Defined in: [packages/db/src/query/builder/functions.ts:115](https://github.com/ function eq(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:119](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L119) +Defined in: [packages/db/src/query/builder/functions.ts:137](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L137) ### Type Parameters @@ -67,7 +67,7 @@ Defined in: [packages/db/src/query/builder/functions.ts:119](https://github.com/ function eq(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:123](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L123) +Defined in: [packages/db/src/query/builder/functions.ts:141](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L141) ### Type Parameters diff --git a/docs/reference/functions/findIndexForField.md b/docs/reference/functions/findIndexForField.md new file mode 100644 index 000000000..aaab37d8e --- /dev/null +++ b/docs/reference/functions/findIndexForField.md @@ -0,0 +1,44 @@ +--- +id: findIndexForField +title: findIndexForField +--- + +# Function: findIndexForField() + +```ts +function findIndexForField( + collection, + fieldPath, + compareOptions?): + | IndexInterface + | undefined; +``` + +Defined in: [packages/db/src/utils/index-optimization.ts:37](https://github.com/TanStack/db/blob/main/packages/db/src/utils/index-optimization.ts#L37) + +Finds an index that matches a given field path + +## Type Parameters + +### TKey + +`TKey` *extends* `string` \| `number` + +## Parameters + +### collection + +[`CollectionLike`](../interfaces/CollectionLike.md)\<`any`, `TKey`\> + +### fieldPath + +`string`[] + +### compareOptions? + +`CompareOptions` + +## Returns + + \| [`IndexInterface`](../interfaces/IndexInterface.md)\<`TKey`\> + \| `undefined` diff --git a/docs/reference/functions/getIndexDevModeConfig.md b/docs/reference/functions/getIndexDevModeConfig.md new file mode 100644 index 000000000..76179b354 --- /dev/null +++ b/docs/reference/functions/getIndexDevModeConfig.md @@ -0,0 +1,18 @@ +--- +id: getIndexDevModeConfig +title: getIndexDevModeConfig +--- + +# Function: getIndexDevModeConfig() + +```ts +function getIndexDevModeConfig(): IndexDevModeConfig; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:59](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L59) + +Get current dev mode configuration + +## Returns + +[`IndexDevModeConfig`](../interfaces/IndexDevModeConfig.md) diff --git a/docs/reference/functions/getQueryPatterns.md b/docs/reference/functions/getQueryPatterns.md new file mode 100644 index 000000000..f49ee3f3a --- /dev/null +++ b/docs/reference/functions/getQueryPatterns.md @@ -0,0 +1,28 @@ +--- +id: getQueryPatterns +title: getQueryPatterns +--- + +# Function: getQueryPatterns() + +```ts +function getQueryPatterns(): Map; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:164](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L164) + +Get query patterns (useful for debugging/testing) + +## Returns + +`Map`\<`string`, \{ + `avgTimeMs`: `number`; + `fieldPath`: `string`[]; + `queryCount`: `number`; + `totalTimeMs`: `number`; +\}\> diff --git a/docs/reference/functions/gt.md b/docs/reference/functions/gt.md index 7a6cb1589..42f0ff188 100644 --- a/docs/reference/functions/gt.md +++ b/docs/reference/functions/gt.md @@ -11,7 +11,7 @@ title: gt function gt(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:128](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L128) +Defined in: [packages/db/src/query/builder/functions.ts:146](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L146) ### Type Parameters @@ -39,7 +39,7 @@ Defined in: [packages/db/src/query/builder/functions.ts:128](https://github.com/ function gt(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:132](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L132) +Defined in: [packages/db/src/query/builder/functions.ts:150](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L150) ### Type Parameters @@ -67,7 +67,7 @@ Defined in: [packages/db/src/query/builder/functions.ts:132](https://github.com/ function gt(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:136](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L136) +Defined in: [packages/db/src/query/builder/functions.ts:154](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L154) ### Type Parameters diff --git a/docs/reference/functions/gte.md b/docs/reference/functions/gte.md index 6a5f0c6e8..18aecd8c6 100644 --- a/docs/reference/functions/gte.md +++ b/docs/reference/functions/gte.md @@ -11,7 +11,7 @@ title: gte function gte(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:141](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L141) +Defined in: [packages/db/src/query/builder/functions.ts:159](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L159) ### Type Parameters @@ -39,7 +39,7 @@ Defined in: [packages/db/src/query/builder/functions.ts:141](https://github.com/ function gte(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:145](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L145) +Defined in: [packages/db/src/query/builder/functions.ts:163](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L163) ### Type Parameters @@ -67,7 +67,7 @@ Defined in: [packages/db/src/query/builder/functions.ts:145](https://github.com/ function gte(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:149](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L149) +Defined in: [packages/db/src/query/builder/functions.ts:167](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L167) ### Type Parameters diff --git a/docs/reference/functions/hasVirtualProps.md b/docs/reference/functions/hasVirtualProps.md new file mode 100644 index 000000000..57a2b9c61 --- /dev/null +++ b/docs/reference/functions/hasVirtualProps.md @@ -0,0 +1,36 @@ +--- +id: hasVirtualProps +title: hasVirtualProps +--- + +# Function: hasVirtualProps() + +```ts +function hasVirtualProps(value): value is VirtualRowProps; +``` + +Defined in: [packages/db/src/virtual-props.ts:145](https://github.com/TanStack/db/blob/main/packages/db/src/virtual-props.ts#L145) + +Checks if a value has virtual properties attached. + +## Parameters + +### value + +`unknown` + +The value to check + +## Returns + +value is VirtualRowProps\ + +true if the value has virtual properties + +## Example + +```typescript +if (hasVirtualProps(row)) { + console.log('Synced:', row.$synced) +} +``` diff --git a/docs/reference/functions/ilike.md b/docs/reference/functions/ilike.md index 7f422aa0c..faf4f8237 100644 --- a/docs/reference/functions/ilike.md +++ b/docs/reference/functions/ilike.md @@ -9,7 +9,7 @@ title: ilike function ilike(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:252](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L252) +Defined in: [packages/db/src/query/builder/functions.ts:270](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L270) ## Parameters diff --git a/docs/reference/functions/inArray.md b/docs/reference/functions/inArray.md index 5f93c467b..6a8d54529 100644 --- a/docs/reference/functions/inArray.md +++ b/docs/reference/functions/inArray.md @@ -9,17 +9,17 @@ title: inArray function inArray(value, array): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:237](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L237) +Defined in: [packages/db/src/query/builder/functions.ts:255](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L255) ## Parameters ### value -`any` +`ExpressionLike` ### array -`any` +`ExpressionLike` ## Returns diff --git a/docs/reference/functions/isDevModeEnabled.md b/docs/reference/functions/isDevModeEnabled.md new file mode 100644 index 000000000..69fe65720 --- /dev/null +++ b/docs/reference/functions/isDevModeEnabled.md @@ -0,0 +1,18 @@ +--- +id: isDevModeEnabled +title: isDevModeEnabled +--- + +# Function: isDevModeEnabled() + +```ts +function isDevModeEnabled(): boolean; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:66](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L66) + +Check if dev mode is enabled + +## Returns + +`boolean` diff --git a/docs/reference/functions/isNull.md b/docs/reference/functions/isNull.md index 3b7576a6f..cf303fc63 100644 --- a/docs/reference/functions/isNull.md +++ b/docs/reference/functions/isNull.md @@ -9,13 +9,13 @@ title: isNull function isNull(value): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:233](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L233) +Defined in: [packages/db/src/query/builder/functions.ts:251](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L251) ## Parameters ### value -`any` +`ExpressionLike` ## Returns diff --git a/docs/reference/functions/isUndefined.md b/docs/reference/functions/isUndefined.md index 8924d9cd1..49d99d535 100644 --- a/docs/reference/functions/isUndefined.md +++ b/docs/reference/functions/isUndefined.md @@ -9,13 +9,13 @@ title: isUndefined function isUndefined(value): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:229](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L229) +Defined in: [packages/db/src/query/builder/functions.ts:247](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L247) ## Parameters ### value -`any` +`ExpressionLike` ## Returns diff --git a/docs/reference/functions/length.md b/docs/reference/functions/length.md index 93ae660bd..d452d3a86 100644 --- a/docs/reference/functions/length.md +++ b/docs/reference/functions/length.md @@ -9,13 +9,13 @@ title: length function length(arg): NumericFunctionReturnType; ``` -Defined in: [packages/db/src/query/builder/functions.ts:273](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L273) +Defined in: [packages/db/src/query/builder/functions.ts:291](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L291) ## Type Parameters ### T -`T` *extends* `unknown` +`T` *extends* `ExpressionLike` ## Parameters diff --git a/docs/reference/functions/like.md b/docs/reference/functions/like.md index fdaa7fc93..a05fa1322 100644 --- a/docs/reference/functions/like.md +++ b/docs/reference/functions/like.md @@ -9,7 +9,7 @@ title: like function like(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:244](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L244) +Defined in: [packages/db/src/query/builder/functions.ts:262](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L262) ## Parameters diff --git a/docs/reference/functions/liveQueryCollectionOptions.md b/docs/reference/functions/liveQueryCollectionOptions.md index 43427f374..ce6c21108 100644 --- a/docs/reference/functions/liveQueryCollectionOptions.md +++ b/docs/reference/functions/liveQueryCollectionOptions.md @@ -6,29 +6,33 @@ title: liveQueryCollectionOptions # Function: liveQueryCollectionOptions() ```ts -function liveQueryCollectionOptions(config): CollectionConfigForContext(config): CollectionConfigForContext & object; ``` -Defined in: [packages/db/src/query/live-query-collection.ts:62](https://github.com/TanStack/db/blob/main/packages/db/src/query/live-query-collection.ts#L62) +Defined in: [packages/db/src/query/live-query-collection.ts:72](https://github.com/TanStack/db/blob/main/packages/db/src/query/live-query-collection.ts#L72) Creates live query collection options for use with createCollection ## Type Parameters +### TQuery + +`TQuery` *extends* [`QueryBuilder`](../type-aliases/QueryBuilder.md)\<`any`\> + ### TContext -`TContext` *extends* [`Context`](../interfaces/Context.md) +`TContext` *extends* [`Context`](../interfaces/Context.md) = [`ExtractContext`](../type-aliases/ExtractContext.md)\<`TQuery`\> ### TResult -`TResult` *extends* `object` = \{ \[K in string \| number \| symbol\]: (TContext\["result"\] extends object ? any\[any\] : TContext\["hasJoins"\] extends true ? TContext\["schema"\] : TContext\["schema"\]\[TContext\["fromSourceName"\]\])\[K\] \} +`TResult` *extends* `object` = `RootQueryResult`\<`TContext`\> ## Parameters ### config -[`LiveQueryCollectionConfig`](../interfaces/LiveQueryCollectionConfig.md)\<`TContext`, `TResult`\> +[`LiveQueryCollectionConfig`](../interfaces/LiveQueryCollectionConfig.md)\<`TContext`, `TResult`\> & `object` Configuration options for the live query collection diff --git a/docs/reference/functions/lower.md b/docs/reference/functions/lower.md index a2b6c0ab8..fff4fc083 100644 --- a/docs/reference/functions/lower.md +++ b/docs/reference/functions/lower.md @@ -9,13 +9,13 @@ title: lower function lower(arg): StringFunctionReturnType; ``` -Defined in: [packages/db/src/query/builder/functions.ts:267](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L267) +Defined in: [packages/db/src/query/builder/functions.ts:285](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L285) ## Type Parameters ### T -`T` *extends* `unknown` +`T` *extends* `ExpressionLike` ## Parameters diff --git a/docs/reference/functions/lt.md b/docs/reference/functions/lt.md index b7c95cdf7..7c204f4a9 100644 --- a/docs/reference/functions/lt.md +++ b/docs/reference/functions/lt.md @@ -11,7 +11,7 @@ title: lt function lt(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:154](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L154) +Defined in: [packages/db/src/query/builder/functions.ts:172](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L172) ### Type Parameters @@ -39,7 +39,7 @@ Defined in: [packages/db/src/query/builder/functions.ts:154](https://github.com/ function lt(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:158](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L158) +Defined in: [packages/db/src/query/builder/functions.ts:176](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L176) ### Type Parameters @@ -67,7 +67,7 @@ Defined in: [packages/db/src/query/builder/functions.ts:158](https://github.com/ function lt(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:162](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L162) +Defined in: [packages/db/src/query/builder/functions.ts:180](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L180) ### Type Parameters diff --git a/docs/reference/functions/lte.md b/docs/reference/functions/lte.md index d71cacef0..2b2b5423c 100644 --- a/docs/reference/functions/lte.md +++ b/docs/reference/functions/lte.md @@ -11,7 +11,7 @@ title: lte function lte(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:167](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L167) +Defined in: [packages/db/src/query/builder/functions.ts:185](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L185) ### Type Parameters @@ -39,7 +39,7 @@ Defined in: [packages/db/src/query/builder/functions.ts:167](https://github.com/ function lte(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:171](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L171) +Defined in: [packages/db/src/query/builder/functions.ts:189](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L189) ### Type Parameters @@ -67,7 +67,7 @@ Defined in: [packages/db/src/query/builder/functions.ts:171](https://github.com/ function lte(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:175](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L175) +Defined in: [packages/db/src/query/builder/functions.ts:193](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L193) ### Type Parameters diff --git a/docs/reference/functions/max.md b/docs/reference/functions/max.md index 81889962b..008439a7d 100644 --- a/docs/reference/functions/max.md +++ b/docs/reference/functions/max.md @@ -9,13 +9,13 @@ title: max function max(arg): AggregateReturnType; ``` -Defined in: [packages/db/src/query/builder/functions.ts:323](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L323) +Defined in: [packages/db/src/query/builder/functions.ts:382](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L382) ## Type Parameters ### T -`T` *extends* `unknown` +`T` *extends* `ExpressionLike` ## Parameters diff --git a/docs/reference/functions/min.md b/docs/reference/functions/min.md index 6335fff82..8c5788295 100644 --- a/docs/reference/functions/min.md +++ b/docs/reference/functions/min.md @@ -9,13 +9,13 @@ title: min function min(arg): AggregateReturnType; ``` -Defined in: [packages/db/src/query/builder/functions.ts:319](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L319) +Defined in: [packages/db/src/query/builder/functions.ts:378](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L378) ## Type Parameters ### T -`T` *extends* `unknown` +`T` *extends* `ExpressionLike` ## Parameters diff --git a/docs/reference/functions/not.md b/docs/reference/functions/not.md index 3a5214236..e6020ac2d 100644 --- a/docs/reference/functions/not.md +++ b/docs/reference/functions/not.md @@ -9,13 +9,13 @@ title: not function not(value): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:224](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L224) +Defined in: [packages/db/src/query/builder/functions.ts:242](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L242) ## Parameters ### value -`any` +`ExpressionLike` ## Returns diff --git a/docs/reference/functions/optimizeExpressionWithIndexes.md b/docs/reference/functions/optimizeExpressionWithIndexes.md new file mode 100644 index 000000000..31d06210a --- /dev/null +++ b/docs/reference/functions/optimizeExpressionWithIndexes.md @@ -0,0 +1,38 @@ +--- +id: optimizeExpressionWithIndexes +title: optimizeExpressionWithIndexes +--- + +# Function: optimizeExpressionWithIndexes() + +```ts +function optimizeExpressionWithIndexes(expression, collection): OptimizationResult; +``` + +Defined in: [packages/db/src/utils/index-optimization.ts:100](https://github.com/TanStack/db/blob/main/packages/db/src/utils/index-optimization.ts#L100) + +Optimizes a query expression using available indexes to find matching keys + +## Type Parameters + +### T + +`T` *extends* `object` + +### TKey + +`TKey` *extends* `string` \| `number` + +## Parameters + +### expression + +[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md) + +### collection + +[`CollectionLike`](../interfaces/CollectionLike.md)\<`T`, `TKey`\> + +## Returns + +`OptimizationResult`\<`TKey`\> diff --git a/docs/reference/functions/or.md b/docs/reference/functions/or.md index 351e72ce8..95adf2ff2 100644 --- a/docs/reference/functions/or.md +++ b/docs/reference/functions/or.md @@ -11,17 +11,17 @@ title: or function or(left, right): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:203](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L203) +Defined in: [packages/db/src/query/builder/functions.ts:221](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L221) ### Parameters #### left -`any` +`ExpressionLike` #### right -`any` +`ExpressionLike` ### Returns @@ -36,21 +36,21 @@ function or( rest): BasicExpression; ``` -Defined in: [packages/db/src/query/builder/functions.ts:207](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L207) +Defined in: [packages/db/src/query/builder/functions.ts:225](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L225) ### Parameters #### left -`any` +`ExpressionLike` #### right -`any` +`ExpressionLike` #### rest -...`any`[] +...`ExpressionLike`[] ### Returns diff --git a/docs/reference/functions/queryOnce.md b/docs/reference/functions/queryOnce.md index 7adb84312..f27984214 100644 --- a/docs/reference/functions/queryOnce.md +++ b/docs/reference/functions/queryOnce.md @@ -8,10 +8,10 @@ title: queryOnce ## Call Signature ```ts -function queryOnce(queryFn): Promise>; +function queryOnce(queryFn): Promise>>; ``` -Defined in: [packages/db/src/query/query-once.ts:47](https://github.com/TanStack/db/blob/main/packages/db/src/query/query-once.ts#L47) +Defined in: [packages/db/src/query/query-once.ts:59](https://github.com/TanStack/db/blob/main/packages/db/src/query/query-once.ts#L59) Executes a one-shot query and returns the results as an array. @@ -24,21 +24,25 @@ and automatically cleans up the collection. It's ideal for: ### Type Parameters -#### TContext +#### TQueryFn -`TContext` *extends* [`Context`](../interfaces/Context.md) +`TQueryFn` *extends* (`q`) => [`QueryBuilder`](../type-aliases/QueryBuilder.md)\<`any`\> + +#### TQuery + +`TQuery` *extends* [`QueryBuilder`](../type-aliases/QueryBuilder.md)\<`any`\> = `ReturnType`\<`TQueryFn`\> ### Parameters #### queryFn -(`q`) => [`QueryBuilder`](../type-aliases/QueryBuilder.md)\<`TContext`\> +`TQueryFn` & `RootQueryFn`\<`TQuery`\> A function that receives the query builder and returns a query ### Returns -`Promise`\<[`InferResultType`](../type-aliases/InferResultType.md)\<`TContext`\>\> +`Promise`\<[`InferResultType`](../type-aliases/InferResultType.md)\<[`ExtractContext`](../type-aliases/ExtractContext.md)\<`TQuery`\>\>\> A promise that resolves to an array of query results @@ -61,30 +65,30 @@ const activeUserNames = await queryOnce((q) => ## Call Signature ```ts -function queryOnce(config): Promise>; +function queryOnce(config): Promise>>; ``` -Defined in: [packages/db/src/query/query-once.ts:68](https://github.com/TanStack/db/blob/main/packages/db/src/query/query-once.ts#L68) +Defined in: [packages/db/src/query/query-once.ts:83](https://github.com/TanStack/db/blob/main/packages/db/src/query/query-once.ts#L83) Executes a one-shot query using a configuration object. ### Type Parameters -#### TContext +#### TQuery -`TContext` *extends* [`Context`](../interfaces/Context.md) +`TQuery` *extends* [`QueryBuilder`](../type-aliases/QueryBuilder.md)\<`any`\> ### Parameters #### config -[`QueryOnceConfig`](../interfaces/QueryOnceConfig.md)\<`TContext`\> +[`QueryOnceConfig`](../interfaces/QueryOnceConfig.md)\<[`ExtractContext`](../type-aliases/ExtractContext.md)\<`TQuery`\>\> & `object` Configuration object with the query function ### Returns -`Promise`\<[`InferResultType`](../type-aliases/InferResultType.md)\<`TContext`\>\> +`Promise`\<[`InferResultType`](../type-aliases/InferResultType.md)\<[`ExtractContext`](../type-aliases/ExtractContext.md)\<`TQuery`\>\>\> A promise that resolves to an array of query results diff --git a/docs/reference/functions/sum.md b/docs/reference/functions/sum.md index 760550dff..3dcf0b62d 100644 --- a/docs/reference/functions/sum.md +++ b/docs/reference/functions/sum.md @@ -9,13 +9,13 @@ title: sum function sum(arg): AggregateReturnType; ``` -Defined in: [packages/db/src/query/builder/functions.ts:315](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L315) +Defined in: [packages/db/src/query/builder/functions.ts:374](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L374) ## Type Parameters ### T -`T` *extends* `unknown` +`T` *extends* `ExpressionLike` ## Parameters diff --git a/docs/reference/functions/toArray.md b/docs/reference/functions/toArray.md new file mode 100644 index 000000000..6e0d154ab --- /dev/null +++ b/docs/reference/functions/toArray.md @@ -0,0 +1,28 @@ +--- +id: toArray +title: toArray +--- + +# Function: toArray() + +```ts +function toArray(query): ToArrayWrapper>; +``` + +Defined in: [packages/db/src/query/builder/functions.ts:451](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L451) + +## Type Parameters + +### TContext + +`TContext` *extends* [`Context`](../interfaces/Context.md) + +## Parameters + +### query + +[`QueryBuilder`](../type-aliases/QueryBuilder.md)\<`TContext`\> + +## Returns + +`ToArrayWrapper`\<`GetRawResult`\<`TContext`\>\> diff --git a/docs/reference/functions/toBooleanPredicate.md b/docs/reference/functions/toBooleanPredicate.md new file mode 100644 index 000000000..e1ed96757 --- /dev/null +++ b/docs/reference/functions/toBooleanPredicate.md @@ -0,0 +1,34 @@ +--- +id: toBooleanPredicate +title: toBooleanPredicate +--- + +# Function: toBooleanPredicate() + +```ts +function toBooleanPredicate(result): boolean; +``` + +Defined in: [packages/db/src/query/compiler/evaluators.ts:54](https://github.com/TanStack/db/blob/main/packages/db/src/query/compiler/evaluators.ts#L54) + +Converts a 3-valued logic result to a boolean for use in WHERE/HAVING filters. +In SQL, UNKNOWN (null) values in WHERE clauses exclude rows, matching false behavior. + +## Parameters + +### result + +The 3-valued logic result: true, false, or null (UNKNOWN) + +`boolean` | `null` + +## Returns + +`boolean` + +true only if result is explicitly true, false otherwise + +Truth table: +- true → true (include row) +- false → false (exclude row) +- null (UNKNOWN) → false (exclude row, matching SQL behavior) diff --git a/docs/reference/functions/trackQuery.md b/docs/reference/functions/trackQuery.md new file mode 100644 index 000000000..c96032f7f --- /dev/null +++ b/docs/reference/functions/trackQuery.md @@ -0,0 +1,35 @@ +--- +id: trackQuery +title: trackQuery +--- + +# Function: trackQuery() + +```ts +function trackQuery( + collectionId, + fieldPath, + executionTimeMs): void; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:96](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L96) + +Track a query for dev mode analysis + +## Parameters + +### collectionId + +`string` + +### fieldPath + +`string`[] + +### executionTimeMs + +`number` + +## Returns + +`void` diff --git a/docs/reference/functions/upper.md b/docs/reference/functions/upper.md index af4652235..390fc9fb3 100644 --- a/docs/reference/functions/upper.md +++ b/docs/reference/functions/upper.md @@ -9,13 +9,13 @@ title: upper function upper(arg): StringFunctionReturnType; ``` -Defined in: [packages/db/src/query/builder/functions.ts:261](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L261) +Defined in: [packages/db/src/query/builder/functions.ts:279](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L279) ## Type Parameters ### T -`T` *extends* `unknown` +`T` *extends* `ExpressionLike` ## Parameters diff --git a/docs/reference/index.md b/docs/reference/index.md index ad75b786d..64f9109a3 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -15,6 +15,7 @@ title: "@tanstack/db" - [AggregateNotSupportedError](classes/AggregateNotSupportedError.md) - [BaseIndex](classes/BaseIndex.md) - [BaseQueryBuilder](classes/BaseQueryBuilder.md) +- [BasicIndex](classes/BasicIndex.md) - [BTreeIndex](classes/BTreeIndex.md) - [CannotCombineEmptyExpressionListError](classes/CannotCombineEmptyExpressionListError.md) - [CollectionConfigurationError](classes/CollectionConfigurationError.md) @@ -37,7 +38,6 @@ title: "@tanstack/db" - [FnSelectWithGroupByError](classes/FnSelectWithGroupByError.md) - [GroupByError](classes/GroupByError.md) - [HavingRequiresGroupByError](classes/HavingRequiresGroupByError.md) -- [IndexProxy](classes/IndexProxy.md) - [InvalidCollectionStatusTransitionError](classes/InvalidCollectionStatusTransitionError.md) - [InvalidJoinCondition](classes/InvalidJoinCondition.md) - [InvalidJoinConditionLeftSourceError](classes/InvalidJoinConditionLeftSourceError.md) @@ -55,7 +55,6 @@ title: "@tanstack/db" - [JoinConditionMustBeEqualityError](classes/JoinConditionMustBeEqualityError.md) - [JoinError](classes/JoinError.md) - [KeyUpdateNotAllowedError](classes/KeyUpdateNotAllowedError.md) -- [LazyIndexWrapper](classes/LazyIndexWrapper.md) - [LimitOffsetRequireOrderByError](classes/LimitOffsetRequireOrderByError.md) - [LocalStorageCollectionError](classes/LocalStorageCollectionError.md) - [MissingAliasInputsError](classes/MissingAliasInputsError.md) @@ -78,6 +77,7 @@ title: "@tanstack/db" - [QueryCompilationError](classes/QueryCompilationError.md) - [QueryMustHaveFromClauseError](classes/QueryMustHaveFromClauseError.md) - [QueryOptimizerError](classes/QueryOptimizerError.md) +- [ReverseIndex](classes/ReverseIndex.md) - [SchemaMustBeSynchronousError](classes/SchemaMustBeSynchronousError.md) - [SchemaValidationError](classes/SchemaValidationError.md) - [SerializationError](classes/SerializationError.md) @@ -103,6 +103,7 @@ title: "@tanstack/db" - [UnsupportedFromTypeError](classes/UnsupportedFromTypeError.md) - [UnsupportedJoinSourceTypeError](classes/UnsupportedJoinSourceTypeError.md) - [UnsupportedJoinTypeError](classes/UnsupportedJoinTypeError.md) +- [UnsupportedRootScalarSelectError](classes/UnsupportedRootScalarSelectError.md) - [UpdateKeyNotFoundError](classes/UpdateKeyNotFoundError.md) - [WhereClauseConversionError](classes/WhereClauseConversionError.md) @@ -110,19 +111,26 @@ title: "@tanstack/db" - [BaseCollectionConfig](interfaces/BaseCollectionConfig.md) - [BaseStrategy](interfaces/BaseStrategy.md) -- [BTreeIndexOptions](interfaces/BTreeIndexOptions.md) +- [BasicIndexOptions](interfaces/BasicIndexOptions.md) +- [BTreeRangeQueryOptions](interfaces/BTreeRangeQueryOptions.md) - [ChangeMessage](interfaces/ChangeMessage.md) - [Collection](interfaces/Collection.md) - [CollectionConfig](interfaces/CollectionConfig.md) +- [CollectionIndexMetadata](interfaces/CollectionIndexMetadata.md) - [CollectionLike](interfaces/CollectionLike.md) - [Context](interfaces/Context.md) - [CreateOptimisticActionsOptions](interfaces/CreateOptimisticActionsOptions.md) - [CurrentStateAsChangesOptions](interfaces/CurrentStateAsChangesOptions.md) - [DebounceStrategy](interfaces/DebounceStrategy.md) - [DebounceStrategyOptions](interfaces/DebounceStrategyOptions.md) +- [Effect](interfaces/Effect.md) +- [EffectConfig](interfaces/EffectConfig.md) +- [EffectContext](interfaces/EffectContext.md) +- [IndexDevModeConfig](interfaces/IndexDevModeConfig.md) - [IndexInterface](interfaces/IndexInterface.md) - [IndexOptions](interfaces/IndexOptions.md) - [IndexStats](interfaces/IndexStats.md) +- [IndexSuggestion](interfaces/IndexSuggestion.md) - [InsertConfig](interfaces/InsertConfig.md) - [LiveQueryCollectionConfig](interfaces/LiveQueryCollectionConfig.md) - [LocalOnlyCollectionConfig](interfaces/LocalOnlyCollectionConfig.md) @@ -147,10 +155,12 @@ title: "@tanstack/db" - [SubscriptionStatusEvent](interfaces/SubscriptionStatusEvent.md) - [SubscriptionUnsubscribedEvent](interfaces/SubscriptionUnsubscribedEvent.md) - [SyncConfig](interfaces/SyncConfig.md) +- [SyncMetadataApi](interfaces/SyncMetadataApi.md) - [ThrottleStrategy](interfaces/ThrottleStrategy.md) - [ThrottleStrategyOptions](interfaces/ThrottleStrategyOptions.md) - [Transaction](interfaces/Transaction.md) - [TransactionConfig](interfaces/TransactionConfig.md) +- [VirtualRowProps](interfaces/VirtualRowProps.md) ## Type Aliases @@ -167,6 +177,9 @@ title: "@tanstack/db" - [DeleteKeyMessage](type-aliases/DeleteKeyMessage.md) - [DeleteMutationFn](type-aliases/DeleteMutationFn.md) - [DeleteMutationFnParams](type-aliases/DeleteMutationFnParams.md) +- [DeltaEvent](type-aliases/DeltaEvent.md) +- [DeltaType](type-aliases/DeltaType.md) +- [EffectQueryInput](type-aliases/EffectQueryInput.md) - [ExtractContext](type-aliases/ExtractContext.md) - [FieldPath](type-aliases/FieldPath.md) - [Fn](type-aliases/Fn.md) @@ -176,7 +189,7 @@ title: "@tanstack/db" - [GroupByCallback](type-aliases/GroupByCallback.md) - [IndexConstructor](type-aliases/IndexConstructor.md) - [IndexOperation](type-aliases/IndexOperation.md) -- [IndexResolver](type-aliases/IndexResolver.md) +- [IndexOperation](type-aliases/IndexOperation-1.md) - [InferCollectionType](type-aliases/InferCollectionType.md) - [InferResultType](type-aliases/InferResultType.md) - [InferSchemaInput](type-aliases/InferSchemaInput.md) @@ -235,13 +248,15 @@ title: "@tanstack/db" - [UpdateMutationFn](type-aliases/UpdateMutationFn.md) - [UpdateMutationFnParams](type-aliases/UpdateMutationFnParams.md) - [UtilsRecord](type-aliases/UtilsRecord.md) +- [VirtualOrigin](type-aliases/VirtualOrigin.md) - [WhereCallback](type-aliases/WhereCallback.md) +- [WithoutVirtualProps](type-aliases/WithoutVirtualProps.md) - [WithResult](type-aliases/WithResult.md) +- [WithVirtualProps](type-aliases/WithVirtualProps.md) - [WritableDeep](type-aliases/WritableDeep.md) ## Variables -- [IndexOperation](variables/IndexOperation.md) - [operators](variables/operators.md) - [Query](variables/Query.md) @@ -250,13 +265,18 @@ title: "@tanstack/db" - [add](functions/add.md) - [and](functions/and.md) - [avg](functions/avg.md) +- [clearQueryPatterns](functions/clearQueryPatterns.md) - [coalesce](functions/coalesce.md) +- [compileExpression](functions/compileExpression.md) - [compileQuery](functions/compileQuery.md) +- [compileSingleRowExpression](functions/compileSingleRowExpression.md) - [concat](functions/concat.md) +- [configureIndexDevMode](functions/configureIndexDevMode.md) - [count](functions/count.md) - [createArrayChangeProxy](functions/createArrayChangeProxy.md) - [createChangeProxy](functions/createChangeProxy.md) - [createCollection](functions/createCollection.md) +- [createEffect](functions/createEffect.md) - [createLiveQueryCollection](functions/createLiveQueryCollection.md) - [createOptimisticAction](functions/createOptimisticAction.md) - [createPacedMutations](functions/createPacedMutations.md) @@ -267,11 +287,16 @@ title: "@tanstack/db" - [extractFieldPath](functions/extractFieldPath.md) - [extractSimpleComparisons](functions/extractSimpleComparisons.md) - [extractValue](functions/extractValue.md) +- [findIndexForField](functions/findIndexForField.md) - [getActiveTransaction](functions/getActiveTransaction.md) +- [getIndexDevModeConfig](functions/getIndexDevModeConfig.md) +- [getQueryPatterns](functions/getQueryPatterns.md) - [gt](functions/gt.md) - [gte](functions/gte.md) +- [hasVirtualProps](functions/hasVirtualProps.md) - [ilike](functions/ilike.md) - [inArray](functions/inArray.md) +- [isDevModeEnabled](functions/isDevModeEnabled.md) - [isLimitSubset](functions/isLimitSubset.md) - [isNull](functions/isNull.md) - [isOffsetLimitSubset](functions/isOffsetLimitSubset.md) @@ -291,6 +316,7 @@ title: "@tanstack/db" - [min](functions/min.md) - [minusWherePredicates](functions/minusWherePredicates.md) - [not](functions/not.md) +- [optimizeExpressionWithIndexes](functions/optimizeExpressionWithIndexes.md) - [or](functions/or.md) - [parseLoadSubsetOptions](functions/parseLoadSubsetOptions.md) - [parseOrderByExpression](functions/parseOrderByExpression.md) @@ -299,6 +325,9 @@ title: "@tanstack/db" - [queueStrategy](functions/queueStrategy.md) - [sum](functions/sum.md) - [throttleStrategy](functions/throttleStrategy.md) +- [toArray](functions/toArray.md) +- [toBooleanPredicate](functions/toBooleanPredicate.md) +- [trackQuery](functions/trackQuery.md) - [unionWherePredicates](functions/unionWherePredicates.md) - [upper](functions/upper.md) - [walkExpression](functions/walkExpression.md) diff --git a/docs/reference/interfaces/BTreeIndexOptions.md b/docs/reference/interfaces/BTreeIndexOptions.md deleted file mode 100644 index 0b80dd2b4..000000000 --- a/docs/reference/interfaces/BTreeIndexOptions.md +++ /dev/null @@ -1,44 +0,0 @@ ---- -id: BTreeIndexOptions -title: BTreeIndexOptions ---- - -# Interface: BTreeIndexOptions - -Defined in: [packages/db/src/indexes/btree-index.ts:16](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L16) - -Options for Ordered index - -## Properties - -### compareFn()? - -```ts -optional compareFn: (a, b) => number; -``` - -Defined in: [packages/db/src/indexes/btree-index.ts:17](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L17) - -#### Parameters - -##### a - -`any` - -##### b - -`any` - -#### Returns - -`number` - -*** - -### compareOptions? - -```ts -optional compareOptions: CompareOptions; -``` - -Defined in: [packages/db/src/indexes/btree-index.ts:18](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L18) diff --git a/docs/reference/interfaces/BTreeRangeQueryOptions.md b/docs/reference/interfaces/BTreeRangeQueryOptions.md new file mode 100644 index 000000000..080fcc45b --- /dev/null +++ b/docs/reference/interfaces/BTreeRangeQueryOptions.md @@ -0,0 +1,50 @@ +--- +id: BTreeRangeQueryOptions +title: BTreeRangeQueryOptions +--- + +# Interface: BTreeRangeQueryOptions + +Defined in: [packages/db/src/indexes/btree-index.ts:24](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L24) + +Options for range queries + +## Properties + +### from? + +```ts +optional from: any; +``` + +Defined in: [packages/db/src/indexes/btree-index.ts:25](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L25) + +*** + +### fromInclusive? + +```ts +optional fromInclusive: boolean; +``` + +Defined in: [packages/db/src/indexes/btree-index.ts:27](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L27) + +*** + +### to? + +```ts +optional to: any; +``` + +Defined in: [packages/db/src/indexes/btree-index.ts:26](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L26) + +*** + +### toInclusive? + +```ts +optional toInclusive: boolean; +``` + +Defined in: [packages/db/src/indexes/btree-index.ts:28](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L28) diff --git a/docs/reference/interfaces/BaseCollectionConfig.md b/docs/reference/interfaces/BaseCollectionConfig.md index 8d5a8d7d1..cf0e34c7d 100644 --- a/docs/reference/interfaces/BaseCollectionConfig.md +++ b/docs/reference/interfaces/BaseCollectionConfig.md @@ -5,7 +5,7 @@ title: BaseCollectionConfig # Interface: BaseCollectionConfig\ -Defined in: [packages/db/src/types.ts:499](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L499) +Defined in: [packages/db/src/types.ts:521](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L521) ## Extended by @@ -42,7 +42,7 @@ Defined in: [packages/db/src/types.ts:499](https://github.com/TanStack/db/blob/m optional autoIndex: "off" | "eager"; ``` -Defined in: [packages/db/src/types.ts:548](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L548) +Defined in: [packages/db/src/types.ts:571](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L571) Auto-indexing mode for the collection. When enabled, indexes will be automatically created for simple where expressions. @@ -50,13 +50,14 @@ When enabled, indexes will be automatically created for simple where expressions #### Default ```ts -"eager" +"off" ``` #### Description -- "off": No automatic indexing -- "eager": Automatically create indexes for simple where expressions in subscribeChanges (default) +- "off": No automatic indexing (default). Use explicit indexes for better bundle size. +- "eager": Automatically create indexes for simple where expressions in subscribeChanges. + Requires setting defaultIndexType. *** @@ -66,7 +67,7 @@ When enabled, indexes will be automatically created for simple where expressions optional compare: (x, y) => number; ``` -Defined in: [packages/db/src/types.ts:559](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L559) +Defined in: [packages/db/src/types.ts:596](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L596) Optional function to compare two items. This is used to order the items in the collection. @@ -100,13 +101,37 @@ compare: (x, y) => x.createdAt.getTime() - y.createdAt.getTime() *** +### defaultIndexType? + +```ts +optional defaultIndexType: IndexConstructor; +``` + +Defined in: [packages/db/src/types.ts:585](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L585) + +Default index type to use when creating indexes without an explicit type. +Required for auto-indexing. Import from '@tanstack/db'. + +#### Example + +```ts +import { BasicIndex } from '@tanstack/db' +const collection = createCollection({ + defaultIndexType: BasicIndex, + autoIndex: 'eager', + // ... +}) +``` + +*** + ### defaultStringCollation? ```ts optional defaultStringCollation: StringCollationConfig; ``` -Defined in: [packages/db/src/types.ts:705](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L705) +Defined in: [packages/db/src/types.ts:742](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L742) Specifies how to compare data in the collection. This should be configured to match data ordering on the backend. @@ -121,7 +146,7 @@ E.g., when using the Electric DB collection these options optional gcTime: number; ``` -Defined in: [packages/db/src/types.ts:528](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L528) +Defined in: [packages/db/src/types.ts:550](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L550) Time in milliseconds after which the collection will be garbage collected when it has no active subscribers. Defaults to 5 minutes (300000ms). @@ -134,7 +159,7 @@ when it has no active subscribers. Defaults to 5 minutes (300000ms). getKey: (item) => TKey; ``` -Defined in: [packages/db/src/types.ts:523](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L523) +Defined in: [packages/db/src/types.ts:545](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L545) Function to extract the ID from an object This is required for update/delete operations which now only accept IDs @@ -168,7 +193,7 @@ getKey: (item) => item.uuid optional id: string; ``` -Defined in: [packages/db/src/types.ts:512](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L512) +Defined in: [packages/db/src/types.ts:534](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L534) *** @@ -178,7 +203,7 @@ Defined in: [packages/db/src/types.ts:512](https://github.com/TanStack/db/blob/m optional onDelete: DeleteMutationFn; ``` -Defined in: [packages/db/src/types.ts:697](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L697) +Defined in: [packages/db/src/types.ts:734](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L734) Optional asynchronous handler function called before a delete operation @@ -242,7 +267,7 @@ onDelete: async ({ transaction, collection }) => { optional onInsert: InsertMutationFn; ``` -Defined in: [packages/db/src/types.ts:610](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L610) +Defined in: [packages/db/src/types.ts:647](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L647) Optional asynchronous handler function called before an insert operation @@ -305,7 +330,7 @@ onInsert: async ({ transaction, collection }) => { optional onUpdate: UpdateMutationFn; ``` -Defined in: [packages/db/src/types.ts:654](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L654) +Defined in: [packages/db/src/types.ts:691](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L691) Optional asynchronous handler function called before an update operation @@ -369,7 +394,7 @@ onUpdate: async ({ transaction, collection }) => { optional schema: TSchema; ``` -Defined in: [packages/db/src/types.ts:513](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L513) +Defined in: [packages/db/src/types.ts:535](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L535) *** @@ -379,7 +404,7 @@ Defined in: [packages/db/src/types.ts:513](https://github.com/TanStack/db/blob/m optional startSync: boolean; ``` -Defined in: [packages/db/src/types.ts:539](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L539) +Defined in: [packages/db/src/types.ts:561](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L561) Whether to eagerly start syncing on collection creation. When true, syncing begins immediately. When false, syncing starts when the first subscriber attaches. @@ -402,7 +427,7 @@ false optional syncMode: SyncMode; ``` -Defined in: [packages/db/src/types.ts:568](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L568) +Defined in: [packages/db/src/types.ts:605](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L605) The mode of sync to use for the collection. @@ -424,4 +449,4 @@ The exact implementation of the sync mode is up to the sync implementation. optional utils: TUtils; ``` -Defined in: [packages/db/src/types.ts:707](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L707) +Defined in: [packages/db/src/types.ts:744](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L744) diff --git a/docs/reference/interfaces/BasicIndexOptions.md b/docs/reference/interfaces/BasicIndexOptions.md new file mode 100644 index 000000000..9918e1e33 --- /dev/null +++ b/docs/reference/interfaces/BasicIndexOptions.md @@ -0,0 +1,44 @@ +--- +id: BasicIndexOptions +title: BasicIndexOptions +--- + +# Interface: BasicIndexOptions + +Defined in: [packages/db/src/indexes/basic-index.ts:24](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L24) + +Options for Basic index + +## Properties + +### compareFn()? + +```ts +optional compareFn: (a, b) => number; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:25](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L25) + +#### Parameters + +##### a + +`any` + +##### b + +`any` + +#### Returns + +`number` + +*** + +### compareOptions? + +```ts +optional compareOptions: CompareOptions; +``` + +Defined in: [packages/db/src/indexes/basic-index.ts:26](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L26) diff --git a/docs/reference/interfaces/ChangeMessage.md b/docs/reference/interfaces/ChangeMessage.md index a88327eed..339b3c350 100644 --- a/docs/reference/interfaces/ChangeMessage.md +++ b/docs/reference/interfaces/ChangeMessage.md @@ -5,7 +5,7 @@ title: ChangeMessage # Interface: ChangeMessage\ -Defined in: [packages/db/src/types.ts:359](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L359) +Defined in: [packages/db/src/types.ts:381](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L381) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [packages/db/src/types.ts:359](https://github.com/TanStack/db/blob/m key: TKey; ``` -Defined in: [packages/db/src/types.ts:363](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L363) +Defined in: [packages/db/src/types.ts:385](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L385) *** @@ -35,7 +35,7 @@ Defined in: [packages/db/src/types.ts:363](https://github.com/TanStack/db/blob/m optional metadata: Record; ``` -Defined in: [packages/db/src/types.ts:367](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L367) +Defined in: [packages/db/src/types.ts:389](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L389) *** @@ -45,7 +45,7 @@ Defined in: [packages/db/src/types.ts:367](https://github.com/TanStack/db/blob/m optional previousValue: T; ``` -Defined in: [packages/db/src/types.ts:365](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L365) +Defined in: [packages/db/src/types.ts:387](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L387) *** @@ -55,7 +55,7 @@ Defined in: [packages/db/src/types.ts:365](https://github.com/TanStack/db/blob/m type: OperationType; ``` -Defined in: [packages/db/src/types.ts:366](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L366) +Defined in: [packages/db/src/types.ts:388](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L388) *** @@ -65,4 +65,4 @@ Defined in: [packages/db/src/types.ts:366](https://github.com/TanStack/db/blob/m value: T; ``` -Defined in: [packages/db/src/types.ts:364](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L364) +Defined in: [packages/db/src/types.ts:386](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L386) diff --git a/docs/reference/interfaces/Collection.md b/docs/reference/interfaces/Collection.md index 940147540..dfc0e6aab 100644 --- a/docs/reference/interfaces/Collection.md +++ b/docs/reference/interfaces/Collection.md @@ -5,7 +5,7 @@ title: Collection # Interface: Collection\ -Defined in: [packages/db/src/collection/index.ts:48](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L48) +Defined in: [packages/db/src/collection/index.ts:54](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L54) Enhanced Collection interface that includes both data type T and utilities TUtils @@ -51,7 +51,7 @@ The type for insert operations (can be different from T for schemas with default _lifecycle: CollectionLifecycleManager; ``` -Defined in: [packages/db/src/collection/index.ts:283](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L283) +Defined in: [packages/db/src/collection/index.ts:289](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L289) #### Inherited from @@ -65,7 +65,7 @@ Defined in: [packages/db/src/collection/index.ts:283](https://github.com/TanStac _state: CollectionStateManager; ``` -Defined in: [packages/db/src/collection/index.ts:295](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L295) +Defined in: [packages/db/src/collection/index.ts:301](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L301) #### Inherited from @@ -79,7 +79,7 @@ Defined in: [packages/db/src/collection/index.ts:295](https://github.com/TanStac _sync: CollectionSyncManager; ``` -Defined in: [packages/db/src/collection/index.ts:284](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L284) +Defined in: [packages/db/src/collection/index.ts:290](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L290) #### Inherited from @@ -93,7 +93,7 @@ Defined in: [packages/db/src/collection/index.ts:284](https://github.com/TanStac config: CollectionConfig; ``` -Defined in: [packages/db/src/collection/index.ts:274](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L274) +Defined in: [packages/db/src/collection/index.ts:280](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L280) #### Inherited from @@ -101,13 +101,31 @@ Defined in: [packages/db/src/collection/index.ts:274](https://github.com/TanStac *** +### deferDataRefresh + +```ts +deferDataRefresh: Promise | null = null; +``` + +Defined in: [packages/db/src/collection/index.ts:308](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L308) + +When set, collection consumers should defer processing incoming data +refreshes until this promise resolves. This prevents stale data from +overwriting optimistic state while pending writes are being applied. + +#### Inherited from + +[`CollectionImpl`](../classes/CollectionImpl.md).[`deferDataRefresh`](../classes/CollectionImpl.md#deferdatarefresh) + +*** + ### id ```ts id: string; ``` -Defined in: [packages/db/src/collection/index.ts:273](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L273) +Defined in: [packages/db/src/collection/index.ts:279](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L279) #### Inherited from @@ -121,7 +139,7 @@ Defined in: [packages/db/src/collection/index.ts:273](https://github.com/TanStac readonly optional singleResult: true; ``` -Defined in: [packages/db/src/collection/index.ts:56](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L56) +Defined in: [packages/db/src/collection/index.ts:62](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L62) *** @@ -131,7 +149,7 @@ Defined in: [packages/db/src/collection/index.ts:56](https://github.com/TanStack readonly utils: TUtils; ``` -Defined in: [packages/db/src/collection/index.ts:55](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L55) +Defined in: [packages/db/src/collection/index.ts:61](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L61) #### Overrides @@ -147,7 +165,7 @@ Defined in: [packages/db/src/collection/index.ts:55](https://github.com/TanStack get compareOptions(): StringCollationConfig; ``` -Defined in: [packages/db/src/collection/index.ts:580](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L580) +Defined in: [packages/db/src/collection/index.ts:643](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L643) ##### Returns @@ -167,7 +185,7 @@ Defined in: [packages/db/src/collection/index.ts:580](https://github.com/TanStac get indexes(): Map>; ``` -Defined in: [packages/db/src/collection/index.ts:565](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L565) +Defined in: [packages/db/src/collection/index.ts:628](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L628) Get resolved indexes for query optimization @@ -189,7 +207,7 @@ Get resolved indexes for query optimization get isLoadingSubset(): boolean; ``` -Defined in: [packages/db/src/collection/index.ts:431](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L431) +Defined in: [packages/db/src/collection/index.ts:456](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L456) Check if the collection is currently loading more data @@ -213,7 +231,7 @@ true if the collection has pending load more operations, false otherwise get size(): number; ``` -Defined in: [packages/db/src/collection/index.ts:468](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L468) +Defined in: [packages/db/src/collection/index.ts:493](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L493) Get the current size of the collection (cached) @@ -232,10 +250,10 @@ Get the current size of the collection (cached) #### Get Signature ```ts -get state(): Map; +get state(): Map>; ``` -Defined in: [packages/db/src/collection/index.ts:757](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L757) +Defined in: [packages/db/src/collection/index.ts:820](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L820) Gets the current state of the collection as a Map @@ -257,7 +275,7 @@ if (itemsMap.has("todo-1")) { ##### Returns -`Map`\<`TKey`, `TOutput`\> +`Map`\<`TKey`, [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\>\> Map containing all items in the collection, with keys as identifiers @@ -275,7 +293,7 @@ Map containing all items in the collection, with keys as identifiers get status(): CollectionStatus; ``` -Defined in: [packages/db/src/collection/index.ts:386](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L386) +Defined in: [packages/db/src/collection/index.ts:411](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L411) Gets the current status of the collection @@ -297,7 +315,7 @@ Gets the current status of the collection get subscriberCount(): number; ``` -Defined in: [packages/db/src/collection/index.ts:393](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L393) +Defined in: [packages/db/src/collection/index.ts:418](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L418) Get the number of subscribers to the collection @@ -316,16 +334,16 @@ Get the number of subscribers to the collection #### Get Signature ```ts -get toArray(): TOutput[]; +get toArray(): WithVirtualProps[]; ``` -Defined in: [packages/db/src/collection/index.ts:786](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L786) +Defined in: [packages/db/src/collection/index.ts:849](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L849) Gets the current state of the collection as an Array ##### Returns -`TOutput`[] +[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`TOutput`, `TKey`\>[] An Array containing all items in the collection @@ -338,16 +356,16 @@ An Array containing all items in the collection ### \[iterator\]() ```ts -iterator: IterableIterator<[TKey, T]>; +iterator: IterableIterator<[TKey, WithVirtualProps]>; ``` -Defined in: [packages/db/src/collection/index.ts:496](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L496) +Defined in: [packages/db/src/collection/index.ts:531](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L531) Get all entries (virtual derived state) #### Returns -`IterableIterator`\<\[`TKey`, `T`\]\> +`IterableIterator`\<\[`TKey`, [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>\]\> #### Inherited from @@ -361,7 +379,7 @@ Get all entries (virtual derived state) cleanup(): Promise; ``` -Defined in: [packages/db/src/collection/index.ts:923](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L923) +Defined in: [packages/db/src/collection/index.ts:988](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L988) Clean up the collection by stopping sync and clearing data This can be called manually or automatically by garbage collection @@ -379,10 +397,10 @@ This can be called manually or automatically by garbage collection ### createIndex() ```ts -createIndex(indexCallback, config): IndexProxy; +createIndex(indexCallback, config): BaseIndex; ``` -Defined in: [packages/db/src/collection/index.ts:555](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L555) +Defined in: [packages/db/src/collection/index.ts:597](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L597) Creates an index on a collection for faster queries. Indexes significantly improve query performance by allowing constant time lookups @@ -390,11 +408,9 @@ and logarithmic time range queries instead of full scans. #### Type Parameters -##### TResolver - -`TResolver` *extends* [`IndexResolver`](../type-aliases/IndexResolver.md)\<`TKey`\> = *typeof* [`BTreeIndex`](../classes/BTreeIndex.md) +##### TIndexType -The type of the index resolver (constructor or async loader) +`TIndexType` *extends* [`IndexConstructor`](../type-aliases/IndexConstructor.md)\<`TKey`\> #### Parameters @@ -406,40 +422,28 @@ Function that extracts the indexed value from each item ##### config -[`IndexOptions`](IndexOptions.md)\<`TResolver`\> = `{}` +[`IndexOptions`](IndexOptions.md)\<`TIndexType`\> = `{}` Configuration including index type and type-specific options #### Returns -[`IndexProxy`](../classes/IndexProxy.md)\<`TKey`\> +[`BaseIndex`](../classes/BaseIndex.md)\<`TKey`\> -An index proxy that provides access to the index when ready +The created index #### Example ```ts -// Create a default B+ tree index -const ageIndex = collection.createIndex((row) => row.age) +import { BasicIndex } from '@tanstack/db' -// Create a ordered index with custom options +// Create an index with explicit type const ageIndex = collection.createIndex((row) => row.age, { - indexType: BTreeIndex, - options: { - compareFn: customComparator, - compareOptions: { direction: 'asc', nulls: 'first', stringSort: 'lexical' } - }, - name: 'age_btree' + indexType: BasicIndex }) -// Create an async-loaded index -const textIndex = collection.createIndex((row) => row.content, { - indexType: async () => { - const { FullTextIndex } = await import('./indexes/fulltext.js') - return FullTextIndex - }, - options: { language: 'en' } -}) +// Create an index with collection's default type +const nameIndex = collection.createIndex((row) => row.name) ``` #### Inherited from @@ -453,10 +457,10 @@ const textIndex = collection.createIndex((row) => row.content, { ```ts currentStateAsChanges(options): | void - | ChangeMessage[]; + | ChangeMessage, string | number>[]; ``` -Defined in: [packages/db/src/collection/index.ts:824](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L824) +Defined in: [packages/db/src/collection/index.ts:887](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L887) Returns the current state of the collection as an array of changes @@ -471,7 +475,7 @@ Options including optional where filter #### Returns \| `void` - \| [`ChangeMessage`](ChangeMessage.md)\<`T`, `string` \| `number`\>[] + \| [`ChangeMessage`](ChangeMessage.md)\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>, `string` \| `number`\>[] An array of changes @@ -504,7 +508,7 @@ const activeChanges = collection.currentStateAsChanges({ delete(keys, config?): Transaction; ``` -Defined in: [packages/db/src/collection/index.ts:734](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L734) +Defined in: [packages/db/src/collection/index.ts:797](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L797) Deletes one or more items from the collection @@ -568,16 +572,16 @@ try { ### entries() ```ts -entries(): IterableIterator<[TKey, T]>; +entries(): IterableIterator<[TKey, WithVirtualProps]>; ``` -Defined in: [packages/db/src/collection/index.ts:489](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L489) +Defined in: [packages/db/src/collection/index.ts:519](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L519) Get all entries (virtual derived state) #### Returns -`IterableIterator`\<\[`TKey`, `T`\]\> +`IterableIterator`\<\[`TKey`, [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>\]\> #### Inherited from @@ -591,7 +595,7 @@ Get all entries (virtual derived state) forEach(callbackfn): void; ``` -Defined in: [packages/db/src/collection/index.ts:503](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L503) +Defined in: [packages/db/src/collection/index.ts:540](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L540) Execute a callback for each entry in the collection @@ -614,10 +618,12 @@ Execute a callback for each entry in the collection ### get() ```ts -get(key): T | undefined; +get(key): + | WithVirtualProps + | undefined; ``` -Defined in: [packages/db/src/collection/index.ts:454](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L454) +Defined in: [packages/db/src/collection/index.ts:479](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L479) Get the current value for a key (virtual derived state) @@ -629,7 +635,8 @@ Get the current value for a key (virtual derived state) #### Returns -`T` \| `undefined` + \| [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\> + \| `undefined` #### Inherited from @@ -637,13 +644,35 @@ Get the current value for a key (virtual derived state) *** +### getIndexMetadata() + +```ts +getIndexMetadata(): CollectionIndexMetadata[]; +``` + +Defined in: [packages/db/src/collection/index.ts:621](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L621) + +Returns a snapshot of current index metadata sorted by indexId. +Persistence wrappers can use this to bootstrap index state if indexes were +created before event listeners were attached. + +#### Returns + +[`CollectionIndexMetadata`](CollectionIndexMetadata.md)[] + +#### Inherited from + +[`CollectionImpl`](../classes/CollectionImpl.md).[`getIndexMetadata`](../classes/CollectionImpl.md#getindexmetadata) + +*** + ### getKeyFromItem() ```ts getKeyFromItem(item): TKey; ``` -Defined in: [packages/db/src/collection/index.ts:518](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L518) +Defined in: [packages/db/src/collection/index.ts:571](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L571) #### Parameters @@ -667,7 +696,7 @@ Defined in: [packages/db/src/collection/index.ts:518](https://github.com/TanStac has(key): boolean; ``` -Defined in: [packages/db/src/collection/index.ts:461](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L461) +Defined in: [packages/db/src/collection/index.ts:486](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L486) Check if a key exists in the collection (virtual derived state) @@ -693,7 +722,7 @@ Check if a key exists in the collection (virtual derived state) insert(data, config?): Transaction>; ``` -Defined in: [packages/db/src/collection/index.ts:621](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L621) +Defined in: [packages/db/src/collection/index.ts:684](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L684) Inserts one or more items into the collection @@ -767,7 +796,7 @@ try { isReady(): boolean; ``` -Defined in: [packages/db/src/collection/index.ts:423](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L423) +Defined in: [packages/db/src/collection/index.ts:448](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L448) Check if the collection is ready for use Returns true if the collection has been marked as ready by its sync implementation @@ -801,7 +830,7 @@ if (collection.isReady()) { keys(): IterableIterator; ``` -Defined in: [packages/db/src/collection/index.ts:475](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L475) +Defined in: [packages/db/src/collection/index.ts:500](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L500) Get all keys (virtual derived state) @@ -821,7 +850,7 @@ Get all keys (virtual derived state) map(callbackfn): U[]; ``` -Defined in: [packages/db/src/collection/index.ts:512](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L512) +Defined in: [packages/db/src/collection/index.ts:556](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L556) Create a new array with the results of calling a function for each entry in the collection @@ -853,7 +882,7 @@ Create a new array with the results of calling a function for each entry in the off(event, callback): void; ``` -Defined in: [packages/db/src/collection/index.ts:902](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L902) +Defined in: [packages/db/src/collection/index.ts:967](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L967) Unsubscribe from a collection event @@ -871,6 +900,8 @@ Unsubscribe from a collection event \| `"subscribers:change"` \| `"loadingSubset:change"` \| `"truncate"` + \| `"index:added"` + \| `"index:removed"` #### Parameters @@ -898,7 +929,7 @@ Unsubscribe from a collection event on(event, callback): () => void; ``` -Defined in: [packages/db/src/collection/index.ts:882](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L882) +Defined in: [packages/db/src/collection/index.ts:947](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L947) Subscribe to a collection event @@ -916,6 +947,8 @@ Subscribe to a collection event \| `"subscribers:change"` \| `"loadingSubset:change"` \| `"truncate"` + \| `"index:added"` + \| `"index:removed"` #### Parameters @@ -949,7 +982,7 @@ Subscribe to a collection event once(event, callback): () => void; ``` -Defined in: [packages/db/src/collection/index.ts:892](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L892) +Defined in: [packages/db/src/collection/index.ts:957](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L957) Subscribe to a collection event once @@ -967,6 +1000,8 @@ Subscribe to a collection event once \| `"subscribers:change"` \| `"loadingSubset:change"` \| `"truncate"` + \| `"index:added"` + \| `"index:removed"` #### Parameters @@ -1000,7 +1035,7 @@ Subscribe to a collection event once onFirstReady(callback): void; ``` -Defined in: [packages/db/src/collection/index.ts:407](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L407) +Defined in: [packages/db/src/collection/index.ts:432](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L432) Register a callback to be executed when the collection first becomes ready Useful for preloading collections @@ -1038,7 +1073,7 @@ collection.onFirstReady(() => { preload(): Promise; ``` -Defined in: [packages/db/src/collection/index.ts:447](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L447) +Defined in: [packages/db/src/collection/index.ts:472](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L472) Preload the collection data by starting sync if not already started Multiple concurrent calls will share the same promise @@ -1053,13 +1088,44 @@ Multiple concurrent calls will share the same promise *** +### removeIndex() + +```ts +removeIndex(indexOrId): boolean; +``` + +Defined in: [packages/db/src/collection/index.ts:612](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L612) + +Removes an index created with createIndex. +Returns true when an index existed and was removed. + +Best-effort semantics: removing an index guarantees it is detached from +collection query planning. Existing index proxy references should be treated +as invalid after removal. + +#### Parameters + +##### indexOrId + +`number` | [`BaseIndex`](../classes/BaseIndex.md)\<`TKey`\> + +#### Returns + +`boolean` + +#### Inherited from + +[`CollectionImpl`](../classes/CollectionImpl.md).[`removeIndex`](../classes/CollectionImpl.md#removeindex) + +*** + ### startSyncImmediate() ```ts startSyncImmediate(): void; ``` -Defined in: [packages/db/src/collection/index.ts:439](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L439) +Defined in: [packages/db/src/collection/index.ts:464](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L464) Start sync immediately - internal method for compiled queries This bypasses lazy loading for special cases like live query results @@ -1077,17 +1143,17 @@ This bypasses lazy loading for special cases like live query results ### stateWhenReady() ```ts -stateWhenReady(): Promise>; +stateWhenReady(): Promise>>; ``` -Defined in: [packages/db/src/collection/index.ts:771](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L771) +Defined in: [packages/db/src/collection/index.ts:834](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L834) Gets the current state of the collection as a Map, but only resolves when data is available Waits for the first sync commit to complete before resolving #### Returns -`Promise`\<`Map`\<`TKey`, `T`\>\> +`Promise`\<`Map`\<`TKey`, [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>\>\> Promise that resolves to a Map containing all items in the collection @@ -1103,7 +1169,7 @@ Promise that resolves to a Map containing all items in the collection subscribeChanges(callback, options): CollectionSubscription; ``` -Defined in: [packages/db/src/collection/index.ts:872](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L872) +Defined in: [packages/db/src/collection/index.ts:935](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L935) Subscribe to changes in the collection @@ -1117,7 +1183,7 @@ Function called when items change ##### options -[`SubscribeChangesOptions`](SubscribeChangesOptions.md)\<`T`\> = `{}` +[`SubscribeChangesOptions`](SubscribeChangesOptions.md)\<`T`, `TKey`\> = `{}` Subscription options including includeInitialState and where filter @@ -1179,17 +1245,17 @@ const subscription = collection.subscribeChanges((changes) => { ### toArrayWhenReady() ```ts -toArrayWhenReady(): Promise; +toArrayWhenReady(): Promise[]>; ``` -Defined in: [packages/db/src/collection/index.ts:796](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L796) +Defined in: [packages/db/src/collection/index.ts:859](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L859) Gets the current state of the collection as an Array, but only resolves when data is available Waits for the first sync commit to complete before resolving #### Returns -`Promise`\<`T`[]\> +`Promise`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>[]\> Promise that resolves to an Array containing all items in the collection @@ -1207,7 +1273,7 @@ Promise that resolves to an Array containing all items in the collection update(key, callback): Transaction; ``` -Defined in: [packages/db/src/collection/index.ts:666](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L666) +Defined in: [packages/db/src/collection/index.ts:729](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L729) Updates one or more items in the collection using a callback function @@ -1282,7 +1348,7 @@ update( callback): Transaction; ``` -Defined in: [packages/db/src/collection/index.ts:672](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L672) +Defined in: [packages/db/src/collection/index.ts:735](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L735) Updates one or more items in the collection using a callback function @@ -1360,7 +1426,7 @@ try { update(id, callback): Transaction; ``` -Defined in: [packages/db/src/collection/index.ts:679](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L679) +Defined in: [packages/db/src/collection/index.ts:742](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L742) Updates one or more items in the collection using a callback function @@ -1435,7 +1501,7 @@ update( callback): Transaction; ``` -Defined in: [packages/db/src/collection/index.ts:685](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L685) +Defined in: [packages/db/src/collection/index.ts:748](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L748) Updates one or more items in the collection using a callback function @@ -1516,7 +1582,7 @@ validateData( key?): T; ``` -Defined in: [packages/db/src/collection/index.ts:572](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L572) +Defined in: [packages/db/src/collection/index.ts:635](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L635) Validates the data against the schema @@ -1547,16 +1613,16 @@ Validates the data against the schema ### values() ```ts -values(): IterableIterator; +values(): IterableIterator>; ``` -Defined in: [packages/db/src/collection/index.ts:482](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L482) +Defined in: [packages/db/src/collection/index.ts:507](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L507) Get all values (virtual derived state) #### Returns -`IterableIterator`\<`T`\> +`IterableIterator`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>\> #### Inherited from @@ -1570,7 +1636,7 @@ Get all values (virtual derived state) waitFor(event, timeout?): Promise; ``` -Defined in: [packages/db/src/collection/index.ts:912](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L912) +Defined in: [packages/db/src/collection/index.ts:977](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L977) Wait for a collection event @@ -1588,6 +1654,8 @@ Wait for a collection event \| `"subscribers:change"` \| `"loadingSubset:change"` \| `"truncate"` + \| `"index:added"` + \| `"index:removed"` #### Parameters diff --git a/docs/reference/interfaces/CollectionConfig.md b/docs/reference/interfaces/CollectionConfig.md index 277ad72e6..6d72de9c2 100644 --- a/docs/reference/interfaces/CollectionConfig.md +++ b/docs/reference/interfaces/CollectionConfig.md @@ -5,7 +5,7 @@ title: CollectionConfig # Interface: CollectionConfig\ -Defined in: [packages/db/src/types.ts:710](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L710) +Defined in: [packages/db/src/types.ts:747](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L747) ## Extends @@ -37,7 +37,7 @@ Defined in: [packages/db/src/types.ts:710](https://github.com/TanStack/db/blob/m optional autoIndex: "off" | "eager"; ``` -Defined in: [packages/db/src/types.ts:548](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L548) +Defined in: [packages/db/src/types.ts:571](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L571) Auto-indexing mode for the collection. When enabled, indexes will be automatically created for simple where expressions. @@ -45,13 +45,14 @@ When enabled, indexes will be automatically created for simple where expressions #### Default ```ts -"eager" +"off" ``` #### Description -- "off": No automatic indexing -- "eager": Automatically create indexes for simple where expressions in subscribeChanges (default) +- "off": No automatic indexing (default). Use explicit indexes for better bundle size. +- "eager": Automatically create indexes for simple where expressions in subscribeChanges. + Requires setting defaultIndexType. #### Inherited from @@ -65,7 +66,7 @@ When enabled, indexes will be automatically created for simple where expressions optional compare: (x, y) => number; ``` -Defined in: [packages/db/src/types.ts:559](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L559) +Defined in: [packages/db/src/types.ts:596](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L596) Optional function to compare two items. This is used to order the items in the collection. @@ -103,13 +104,41 @@ compare: (x, y) => x.createdAt.getTime() - y.createdAt.getTime() *** +### defaultIndexType? + +```ts +optional defaultIndexType: IndexConstructor; +``` + +Defined in: [packages/db/src/types.ts:585](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L585) + +Default index type to use when creating indexes without an explicit type. +Required for auto-indexing. Import from '@tanstack/db'. + +#### Example + +```ts +import { BasicIndex } from '@tanstack/db' +const collection = createCollection({ + defaultIndexType: BasicIndex, + autoIndex: 'eager', + // ... +}) +``` + +#### Inherited from + +[`BaseCollectionConfig`](BaseCollectionConfig.md).[`defaultIndexType`](BaseCollectionConfig.md#defaultindextype) + +*** + ### defaultStringCollation? ```ts optional defaultStringCollation: StringCollationConfig; ``` -Defined in: [packages/db/src/types.ts:705](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L705) +Defined in: [packages/db/src/types.ts:742](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L742) Specifies how to compare data in the collection. This should be configured to match data ordering on the backend. @@ -128,7 +157,7 @@ E.g., when using the Electric DB collection these options optional gcTime: number; ``` -Defined in: [packages/db/src/types.ts:528](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L528) +Defined in: [packages/db/src/types.ts:550](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L550) Time in milliseconds after which the collection will be garbage collected when it has no active subscribers. Defaults to 5 minutes (300000ms). @@ -145,7 +174,7 @@ when it has no active subscribers. Defaults to 5 minutes (300000ms). getKey: (item) => TKey; ``` -Defined in: [packages/db/src/types.ts:523](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L523) +Defined in: [packages/db/src/types.ts:545](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L545) Function to extract the ID from an object This is required for update/delete operations which now only accept IDs @@ -183,7 +212,7 @@ getKey: (item) => item.uuid optional id: string; ``` -Defined in: [packages/db/src/types.ts:512](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L512) +Defined in: [packages/db/src/types.ts:534](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L534) #### Inherited from @@ -197,7 +226,7 @@ Defined in: [packages/db/src/types.ts:512](https://github.com/TanStack/db/blob/m optional onDelete: DeleteMutationFn; ``` -Defined in: [packages/db/src/types.ts:697](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L697) +Defined in: [packages/db/src/types.ts:734](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L734) Optional asynchronous handler function called before a delete operation @@ -265,7 +294,7 @@ onDelete: async ({ transaction, collection }) => { optional onInsert: InsertMutationFn; ``` -Defined in: [packages/db/src/types.ts:610](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L610) +Defined in: [packages/db/src/types.ts:647](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L647) Optional asynchronous handler function called before an insert operation @@ -332,7 +361,7 @@ onInsert: async ({ transaction, collection }) => { optional onUpdate: UpdateMutationFn; ``` -Defined in: [packages/db/src/types.ts:654](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L654) +Defined in: [packages/db/src/types.ts:691](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L691) Optional asynchronous handler function called before an update operation @@ -400,7 +429,7 @@ onUpdate: async ({ transaction, collection }) => { optional schema: TSchema; ``` -Defined in: [packages/db/src/types.ts:513](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L513) +Defined in: [packages/db/src/types.ts:535](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L535) #### Inherited from @@ -414,7 +443,7 @@ Defined in: [packages/db/src/types.ts:513](https://github.com/TanStack/db/blob/m optional startSync: boolean; ``` -Defined in: [packages/db/src/types.ts:539](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L539) +Defined in: [packages/db/src/types.ts:561](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L561) Whether to eagerly start syncing on collection creation. When true, syncing begins immediately. When false, syncing starts when the first subscriber attaches. @@ -441,7 +470,7 @@ false sync: SyncConfig; ``` -Defined in: [packages/db/src/types.ts:716](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L716) +Defined in: [packages/db/src/types.ts:753](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L753) *** @@ -451,7 +480,7 @@ Defined in: [packages/db/src/types.ts:716](https://github.com/TanStack/db/blob/m optional syncMode: SyncMode; ``` -Defined in: [packages/db/src/types.ts:568](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L568) +Defined in: [packages/db/src/types.ts:605](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L605) The mode of sync to use for the collection. @@ -477,7 +506,7 @@ The exact implementation of the sync mode is up to the sync implementation. optional utils: TUtils; ``` -Defined in: [packages/db/src/types.ts:707](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L707) +Defined in: [packages/db/src/types.ts:744](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L744) #### Inherited from diff --git a/docs/reference/interfaces/CollectionIndexMetadata.md b/docs/reference/interfaces/CollectionIndexMetadata.md new file mode 100644 index 000000000..500b6bf6f --- /dev/null +++ b/docs/reference/interfaces/CollectionIndexMetadata.md @@ -0,0 +1,83 @@ +--- +id: CollectionIndexMetadata +title: CollectionIndexMetadata +--- + +# Interface: CollectionIndexMetadata + +Defined in: [packages/db/src/collection/events.ts:70](https://github.com/TanStack/db/blob/main/packages/db/src/collection/events.ts#L70) + +## Properties + +### expression + +```ts +expression: BasicExpression; +``` + +Defined in: [packages/db/src/collection/events.ts:82](https://github.com/TanStack/db/blob/main/packages/db/src/collection/events.ts#L82) + +*** + +### indexId + +```ts +indexId: number; +``` + +Defined in: [packages/db/src/collection/events.ts:80](https://github.com/TanStack/db/blob/main/packages/db/src/collection/events.ts#L80) + +*** + +### name? + +```ts +optional name: string; +``` + +Defined in: [packages/db/src/collection/events.ts:81](https://github.com/TanStack/db/blob/main/packages/db/src/collection/events.ts#L81) + +*** + +### options? + +```ts +optional options: CollectionIndexSerializableValue; +``` + +Defined in: [packages/db/src/collection/events.ts:84](https://github.com/TanStack/db/blob/main/packages/db/src/collection/events.ts#L84) + +*** + +### resolver + +```ts +resolver: CollectionIndexResolverMetadata; +``` + +Defined in: [packages/db/src/collection/events.ts:83](https://github.com/TanStack/db/blob/main/packages/db/src/collection/events.ts#L83) + +*** + +### signature + +```ts +signature: string; +``` + +Defined in: [packages/db/src/collection/events.ts:79](https://github.com/TanStack/db/blob/main/packages/db/src/collection/events.ts#L79) + +Stable signature derived from expression + serializable options. +Non-serializable option fields are intentionally omitted. + +*** + +### signatureVersion + +```ts +signatureVersion: 1; +``` + +Defined in: [packages/db/src/collection/events.ts:74](https://github.com/TanStack/db/blob/main/packages/db/src/collection/events.ts#L74) + +Version for the signature serialization contract. diff --git a/docs/reference/interfaces/CollectionLike.md b/docs/reference/interfaces/CollectionLike.md index 0b8f2e026..cc5593c1d 100644 --- a/docs/reference/interfaces/CollectionLike.md +++ b/docs/reference/interfaces/CollectionLike.md @@ -5,7 +5,7 @@ title: CollectionLike # Interface: CollectionLike\ -Defined in: [packages/db/src/types.ts:13](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L13) +Defined in: [packages/db/src/types.ts:15](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L15) Interface for a collection-like object that provides the necessary methods for the change events system to work @@ -32,7 +32,7 @@ for the change events system to work compareOptions: StringCollationConfig; ``` -Defined in: [packages/db/src/collection/index.ts:580](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L580) +Defined in: [packages/db/src/collection/index.ts:643](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L643) #### Inherited from @@ -46,7 +46,7 @@ Defined in: [packages/db/src/collection/index.ts:580](https://github.com/TanStac id: string; ``` -Defined in: [packages/db/src/collection/index.ts:273](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L273) +Defined in: [packages/db/src/collection/index.ts:279](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L279) #### Inherited from @@ -60,7 +60,7 @@ Defined in: [packages/db/src/collection/index.ts:273](https://github.com/TanStac indexes: Map>; ``` -Defined in: [packages/db/src/collection/index.ts:565](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L565) +Defined in: [packages/db/src/collection/index.ts:628](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L628) #### Inherited from @@ -73,16 +73,16 @@ Pick.indexes ### entries() ```ts -entries(): IterableIterator<[TKey, T]>; +entries(): IterableIterator<[TKey, WithVirtualProps]>; ``` -Defined in: [packages/db/src/collection/index.ts:489](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L489) +Defined in: [packages/db/src/collection/index.ts:519](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L519) Get all entries (virtual derived state) #### Returns -`IterableIterator`\<\[`TKey`, `T`\]\> +`IterableIterator`\<\[`TKey`, [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>\]\> #### Inherited from @@ -95,10 +95,12 @@ Pick.entries ### get() ```ts -get(key): T | undefined; +get(key): + | WithVirtualProps + | undefined; ``` -Defined in: [packages/db/src/collection/index.ts:454](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L454) +Defined in: [packages/db/src/collection/index.ts:479](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L479) Get the current value for a key (virtual derived state) @@ -110,7 +112,8 @@ Get the current value for a key (virtual derived state) #### Returns -`T` \| `undefined` + \| [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\> + \| `undefined` #### Inherited from @@ -126,7 +129,7 @@ Pick.get has(key): boolean; ``` -Defined in: [packages/db/src/collection/index.ts:461](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L461) +Defined in: [packages/db/src/collection/index.ts:486](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L486) Check if a key exists in the collection (virtual derived state) diff --git a/docs/reference/interfaces/Context.md b/docs/reference/interfaces/Context.md index 246dca186..2caa57dab 100644 --- a/docs/reference/interfaces/Context.md +++ b/docs/reference/interfaces/Context.md @@ -5,7 +5,7 @@ title: Context # Interface: Context -Defined in: [packages/db/src/query/builder/types.ts:35](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L35) +Defined in: [packages/db/src/query/builder/types.ts:37](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L37) Context - The central state container for query builder operations @@ -36,7 +36,7 @@ The context evolves through the query builder chain: baseSchema: ContextSchema; ``` -Defined in: [packages/db/src/query/builder/types.ts:37](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L37) +Defined in: [packages/db/src/query/builder/types.ts:39](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L39) *** @@ -46,7 +46,7 @@ Defined in: [packages/db/src/query/builder/types.ts:37](https://github.com/TanSt fromSourceName: string; ``` -Defined in: [packages/db/src/query/builder/types.ts:41](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L41) +Defined in: [packages/db/src/query/builder/types.ts:43](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L43) *** @@ -56,7 +56,17 @@ Defined in: [packages/db/src/query/builder/types.ts:41](https://github.com/TanSt optional hasJoins: boolean; ``` -Defined in: [packages/db/src/query/builder/types.ts:43](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L43) +Defined in: [packages/db/src/query/builder/types.ts:45](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L45) + +*** + +### hasResult? + +```ts +optional hasResult: true; +``` + +Defined in: [packages/db/src/query/builder/types.ts:54](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L54) *** @@ -66,7 +76,7 @@ Defined in: [packages/db/src/query/builder/types.ts:43](https://github.com/TanSt optional joinTypes: Record; ``` -Defined in: [packages/db/src/query/builder/types.ts:45](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L45) +Defined in: [packages/db/src/query/builder/types.ts:47](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L47) *** @@ -76,7 +86,7 @@ Defined in: [packages/db/src/query/builder/types.ts:45](https://github.com/TanSt optional result: any; ``` -Defined in: [packages/db/src/query/builder/types.ts:50](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L50) +Defined in: [packages/db/src/query/builder/types.ts:52](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L52) *** @@ -86,7 +96,7 @@ Defined in: [packages/db/src/query/builder/types.ts:50](https://github.com/TanSt schema: ContextSchema; ``` -Defined in: [packages/db/src/query/builder/types.ts:39](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L39) +Defined in: [packages/db/src/query/builder/types.ts:41](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L41) *** @@ -96,4 +106,4 @@ Defined in: [packages/db/src/query/builder/types.ts:39](https://github.com/TanSt optional singleResult: boolean; ``` -Defined in: [packages/db/src/query/builder/types.ts:52](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L52) +Defined in: [packages/db/src/query/builder/types.ts:56](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L56) diff --git a/docs/reference/interfaces/CreateOptimisticActionsOptions.md b/docs/reference/interfaces/CreateOptimisticActionsOptions.md index 37fa31c3c..c76b7a4d0 100644 --- a/docs/reference/interfaces/CreateOptimisticActionsOptions.md +++ b/docs/reference/interfaces/CreateOptimisticActionsOptions.md @@ -5,7 +5,7 @@ title: CreateOptimisticActionsOptions # Interface: CreateOptimisticActionsOptions\ -Defined in: [packages/db/src/types.ts:179](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L179) +Defined in: [packages/db/src/types.ts:181](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L181) Options for the createOptimisticAction helper @@ -31,7 +31,7 @@ Options for the createOptimisticAction helper optional autoCommit: boolean; ``` -Defined in: [packages/db/src/types.ts:170](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L170) +Defined in: [packages/db/src/types.ts:172](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L172) #### Inherited from @@ -45,7 +45,7 @@ Defined in: [packages/db/src/types.ts:170](https://github.com/TanStack/db/blob/m optional id: string; ``` -Defined in: [packages/db/src/types.ts:168](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L168) +Defined in: [packages/db/src/types.ts:170](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L170) Unique identifier for the transaction @@ -61,7 +61,7 @@ Unique identifier for the transaction optional metadata: Record; ``` -Defined in: [packages/db/src/types.ts:173](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L173) +Defined in: [packages/db/src/types.ts:175](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L175) Custom metadata to associate with the transaction @@ -77,7 +77,7 @@ Custom metadata to associate with the transaction mutationFn: (vars, params) => Promise; ``` -Defined in: [packages/db/src/types.ts:186](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L186) +Defined in: [packages/db/src/types.ts:188](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L188) Function to execute the mutation on the server @@ -103,7 +103,7 @@ Function to execute the mutation on the server onMutate: (vars) => void; ``` -Defined in: [packages/db/src/types.ts:184](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L184) +Defined in: [packages/db/src/types.ts:186](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L186) Function to apply optimistic updates locally before the mutation completes diff --git a/docs/reference/interfaces/CurrentStateAsChangesOptions.md b/docs/reference/interfaces/CurrentStateAsChangesOptions.md index 9f01f10df..accb75274 100644 --- a/docs/reference/interfaces/CurrentStateAsChangesOptions.md +++ b/docs/reference/interfaces/CurrentStateAsChangesOptions.md @@ -5,7 +5,7 @@ title: CurrentStateAsChangesOptions # Interface: CurrentStateAsChangesOptions -Defined in: [packages/db/src/types.ts:840](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L840) +Defined in: [packages/db/src/types.ts:880](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L880) Options for getting current state as changes @@ -17,7 +17,7 @@ Options for getting current state as changes optional limit: number; ``` -Defined in: [packages/db/src/types.ts:844](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L844) +Defined in: [packages/db/src/types.ts:884](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L884) *** @@ -27,7 +27,7 @@ Defined in: [packages/db/src/types.ts:844](https://github.com/TanStack/db/blob/m optional optimizedOnly: boolean; ``` -Defined in: [packages/db/src/types.ts:845](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L845) +Defined in: [packages/db/src/types.ts:885](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L885) *** @@ -37,7 +37,7 @@ Defined in: [packages/db/src/types.ts:845](https://github.com/TanStack/db/blob/m optional orderBy: OrderBy; ``` -Defined in: [packages/db/src/types.ts:843](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L843) +Defined in: [packages/db/src/types.ts:883](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L883) *** @@ -47,6 +47,6 @@ Defined in: [packages/db/src/types.ts:843](https://github.com/TanStack/db/blob/m optional where: BasicExpression; ``` -Defined in: [packages/db/src/types.ts:842](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L842) +Defined in: [packages/db/src/types.ts:882](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L882) Pre-compiled expression for filtering the current state diff --git a/docs/reference/interfaces/Effect.md b/docs/reference/interfaces/Effect.md new file mode 100644 index 000000000..a332987ee --- /dev/null +++ b/docs/reference/interfaces/Effect.md @@ -0,0 +1,38 @@ +--- +id: Effect +title: Effect +--- + +# Interface: Effect + +Defined in: [packages/db/src/query/effect.ts:134](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L134) + +Handle returned by createEffect + +## Properties + +### dispose() + +```ts +dispose: () => Promise; +``` + +Defined in: [packages/db/src/query/effect.ts:136](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L136) + +Dispose the effect. Returns a promise that resolves when in-flight handlers complete. + +#### Returns + +`Promise`\<`void`\> + +*** + +### disposed + +```ts +readonly disposed: boolean; +``` + +Defined in: [packages/db/src/query/effect.ts:138](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L138) + +Whether this effect has been disposed diff --git a/docs/reference/interfaces/EffectConfig.md b/docs/reference/interfaces/EffectConfig.md new file mode 100644 index 000000000..7a8a915ca --- /dev/null +++ b/docs/reference/interfaces/EffectConfig.md @@ -0,0 +1,156 @@ +--- +id: EffectConfig +title: EffectConfig +--- + +# Interface: EffectConfig\ + +Defined in: [packages/db/src/query/effect.ts:93](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L93) + +Effect configuration + +## Type Parameters + +### TRow + +`TRow` *extends* `object` = `Record`\<`string`, `unknown`\> + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + +## Properties + +### id? + +```ts +optional id: string; +``` + +Defined in: [packages/db/src/query/effect.ts:98](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L98) + +Optional ID for debugging/tracing + +*** + +### onBatch? + +```ts +optional onBatch: EffectBatchHandler; +``` + +Defined in: [packages/db/src/query/effect.ts:113](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L113) + +Called once per graph run with all delta events from that batch + +*** + +### onEnter? + +```ts +optional onEnter: EffectEventHandler; +``` + +Defined in: [packages/db/src/query/effect.ts:104](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L104) + +Called once for each row entering the query result + +*** + +### onError()? + +```ts +optional onError: (error, event) => void; +``` + +Defined in: [packages/db/src/query/effect.ts:116](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L116) + +Error handler for exceptions thrown by effect callbacks + +#### Parameters + +##### error + +`Error` + +##### event + +[`DeltaEvent`](../type-aliases/DeltaEvent.md)\<`TRow`, `TKey`\> + +#### Returns + +`void` + +*** + +### onExit? + +```ts +optional onExit: EffectEventHandler; +``` + +Defined in: [packages/db/src/query/effect.ts:110](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L110) + +Called once for each row exiting the query result + +*** + +### onSourceError()? + +```ts +optional onSourceError: (error) => void; +``` + +Defined in: [packages/db/src/query/effect.ts:123](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L123) + +Called when a source collection enters an error or cleaned-up state. +The effect is automatically disposed after this callback fires. +If not provided, the error is logged to console.error. + +#### Parameters + +##### error + +`Error` + +#### Returns + +`void` + +*** + +### onUpdate? + +```ts +optional onUpdate: EffectEventHandler; +``` + +Defined in: [packages/db/src/query/effect.ts:107](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L107) + +Called once for each row updating within the query result + +*** + +### query + +```ts +query: EffectQueryInput; +``` + +Defined in: [packages/db/src/query/effect.ts:101](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L101) + +Query to watch for deltas + +*** + +### skipInitial? + +```ts +optional skipInitial: boolean; +``` + +Defined in: [packages/db/src/query/effect.ts:130](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L130) + +Skip deltas during initial collection load. +Defaults to false (process all deltas including initial sync). +Set to true for effects that should only process new changes. diff --git a/docs/reference/interfaces/EffectContext.md b/docs/reference/interfaces/EffectContext.md new file mode 100644 index 000000000..db13c1ab3 --- /dev/null +++ b/docs/reference/interfaces/EffectContext.md @@ -0,0 +1,34 @@ +--- +id: EffectContext +title: EffectContext +--- + +# Interface: EffectContext + +Defined in: [packages/db/src/query/effect.ts:67](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L67) + +Context passed to effect handlers + +## Properties + +### effectId + +```ts +effectId: string; +``` + +Defined in: [packages/db/src/query/effect.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L69) + +ID of this effect (auto-generated if not provided) + +*** + +### signal + +```ts +signal: AbortSignal; +``` + +Defined in: [packages/db/src/query/effect.ts:71](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L71) + +Aborted when effect.dispose() is called diff --git a/docs/reference/interfaces/IndexDevModeConfig.md b/docs/reference/interfaces/IndexDevModeConfig.md new file mode 100644 index 000000000..90dfadcd9 --- /dev/null +++ b/docs/reference/interfaces/IndexDevModeConfig.md @@ -0,0 +1,56 @@ +--- +id: IndexDevModeConfig +title: IndexDevModeConfig +--- + +# Interface: IndexDevModeConfig + +Defined in: [packages/db/src/indexes/index-registry.ts:15](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L15) + +## Properties + +### collectionSizeThreshold + +```ts +collectionSizeThreshold: number; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:19](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L19) + +Suggest indexes when collection has more than this many items + +*** + +### enabled + +```ts +enabled: boolean; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:17](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L17) + +Enable dev mode index suggestions + +*** + +### onSuggestion + +```ts +onSuggestion: (suggestion) => void | null; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:23](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L23) + +Custom handler for index suggestions + +*** + +### slowQueryThresholdMs + +```ts +slowQueryThresholdMs: number; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:21](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L21) + +Suggest indexes when queries take longer than this (ms) diff --git a/docs/reference/interfaces/IndexInterface.md b/docs/reference/interfaces/IndexInterface.md index 8780bbb97..43400d877 100644 --- a/docs/reference/interfaces/IndexInterface.md +++ b/docs/reference/interfaces/IndexInterface.md @@ -11,7 +11,7 @@ Defined in: [packages/db/src/indexes/base-index.ts:28](https://github.com/TanSta ### TKey -`TKey` *extends* `string` \| `number` \| `undefined` = `string` \| `number` \| `undefined` +`TKey` *extends* `string` \| `number` = `string` \| `number` ## Properties @@ -223,7 +223,7 @@ Defined in: [packages/db/src/indexes/base-index.ts:43](https://github.com/TanSta ##### options -[`RangeQueryOptions`](RangeQueryOptions.md) +[`BTreeRangeQueryOptions`](BTreeRangeQueryOptions.md) #### Returns @@ -243,7 +243,7 @@ Defined in: [packages/db/src/indexes/base-index.ts:44](https://github.com/TanSta ##### options -[`RangeQueryOptions`](RangeQueryOptions.md) +[`BTreeRangeQueryOptions`](BTreeRangeQueryOptions.md) #### Returns diff --git a/docs/reference/interfaces/IndexOptions.md b/docs/reference/interfaces/IndexOptions.md index 3ca169871..c3908219f 100644 --- a/docs/reference/interfaces/IndexOptions.md +++ b/docs/reference/interfaces/IndexOptions.md @@ -3,27 +3,29 @@ id: IndexOptions title: IndexOptions --- -# Interface: IndexOptions\ +# Interface: IndexOptions\ Defined in: [packages/db/src/indexes/index-options.ts:6](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-options.ts#L6) -Enhanced index options that support both sync and async resolvers +Options for creating an index ## Type Parameters -### TResolver +### TIndexType -`TResolver` *extends* [`IndexResolver`](../type-aliases/IndexResolver.md) = [`IndexResolver`](../type-aliases/IndexResolver.md) +`TIndexType` *extends* [`IndexConstructor`](../type-aliases/IndexConstructor.md) = [`IndexConstructor`](../type-aliases/IndexConstructor.md) ## Properties ### indexType? ```ts -optional indexType: TResolver; +optional indexType: TIndexType; ``` -Defined in: [packages/db/src/indexes/index-options.ts:8](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-options.ts#L8) +Defined in: [packages/db/src/indexes/index-options.ts:12](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-options.ts#L12) + +Index type to use (e.g., BasicIndex, BTreeIndex) *** @@ -33,14 +35,18 @@ Defined in: [packages/db/src/indexes/index-options.ts:8](https://github.com/TanS optional name: string; ``` -Defined in: [packages/db/src/indexes/index-options.ts:7](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-options.ts#L7) +Defined in: [packages/db/src/indexes/index-options.ts:10](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-options.ts#L10) + +Optional name for the index *** ### options? ```ts -optional options: TResolver extends IndexConstructor ? TResolver extends (id, expr, name?, options?) => any ? O : never : TResolver extends () => Promise ? TCtor extends (id, expr, name?, options?) => any ? O : never : never; +optional options: TIndexType extends (id, expr, name?, options?) => any ? O : never; ``` -Defined in: [packages/db/src/indexes/index-options.ts:9](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-options.ts#L9) +Defined in: [packages/db/src/indexes/index-options.ts:14](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-options.ts#L14) + +Options passed to the index constructor diff --git a/docs/reference/interfaces/IndexSuggestion.md b/docs/reference/interfaces/IndexSuggestion.md new file mode 100644 index 000000000..24cdd19e5 --- /dev/null +++ b/docs/reference/interfaces/IndexSuggestion.md @@ -0,0 +1,78 @@ +--- +id: IndexSuggestion +title: IndexSuggestion +--- + +# Interface: IndexSuggestion + +Defined in: [packages/db/src/indexes/index-registry.ts:26](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L26) + +## Properties + +### collectionId + +```ts +collectionId: string; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:28](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L28) + +*** + +### collectionSize? + +```ts +optional collectionSize: number; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:31](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L31) + +*** + +### fieldPath + +```ts +fieldPath: string[]; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:29](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L29) + +*** + +### message + +```ts +message: string; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:30](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L30) + +*** + +### queryCount? + +```ts +optional queryCount: number; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:33](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L33) + +*** + +### queryTimeMs? + +```ts +optional queryTimeMs: number; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:32](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L32) + +*** + +### type + +```ts +type: "collection-size" | "slow-query" | "frequent-field"; +``` + +Defined in: [packages/db/src/indexes/index-registry.ts:27](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/index-registry.ts#L27) diff --git a/docs/reference/interfaces/InsertConfig.md b/docs/reference/interfaces/InsertConfig.md index 73a7a4c61..7e4007630 100644 --- a/docs/reference/interfaces/InsertConfig.md +++ b/docs/reference/interfaces/InsertConfig.md @@ -5,7 +5,7 @@ title: InsertConfig # Interface: InsertConfig -Defined in: [packages/db/src/types.ts:417](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L417) +Defined in: [packages/db/src/types.ts:439](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L439) ## Properties @@ -15,7 +15,7 @@ Defined in: [packages/db/src/types.ts:417](https://github.com/TanStack/db/blob/m optional metadata: Record; ``` -Defined in: [packages/db/src/types.ts:418](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L418) +Defined in: [packages/db/src/types.ts:440](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L440) *** @@ -25,6 +25,6 @@ Defined in: [packages/db/src/types.ts:418](https://github.com/TanStack/db/blob/m optional optimistic: boolean; ``` -Defined in: [packages/db/src/types.ts:420](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L420) +Defined in: [packages/db/src/types.ts:442](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L442) Whether to apply optimistic updates immediately. Defaults to true. diff --git a/docs/reference/interfaces/LiveQueryCollectionConfig.md b/docs/reference/interfaces/LiveQueryCollectionConfig.md index bdd05f5ed..6958f4a38 100644 --- a/docs/reference/interfaces/LiveQueryCollectionConfig.md +++ b/docs/reference/interfaces/LiveQueryCollectionConfig.md @@ -5,7 +5,7 @@ title: LiveQueryCollectionConfig # Interface: LiveQueryCollectionConfig\ -Defined in: [packages/db/src/query/live/types.ts:55](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L55) +Defined in: [packages/db/src/query/live/types.ts:59](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L59) Configuration interface for live query collection options @@ -39,7 +39,7 @@ const config: LiveQueryCollectionConfig = { ### TResult -`TResult` *extends* `object` = [`GetResult`](../type-aliases/GetResult.md)\<`TContext`\> & `object` +`TResult` *extends* `object` = `RootQueryResult`\<`TContext`\> ## Properties @@ -49,7 +49,7 @@ const config: LiveQueryCollectionConfig = { optional defaultStringCollation: StringCollationConfig; ``` -Defined in: [packages/db/src/query/live/types.ts:109](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L109) +Defined in: [packages/db/src/query/live/types.ts:115](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L115) Optional compare options for string sorting. If provided, these will be used instead of inheriting from the FROM collection. @@ -62,7 +62,7 @@ If provided, these will be used instead of inheriting from the FROM collection. optional gcTime: number; ``` -Defined in: [packages/db/src/query/live/types.ts:98](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L98) +Defined in: [packages/db/src/query/live/types.ts:104](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L104) GC time for the collection @@ -74,7 +74,7 @@ GC time for the collection optional getKey: (item) => string | number; ``` -Defined in: [packages/db/src/query/live/types.ts:76](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L76) +Defined in: [packages/db/src/query/live/types.ts:82](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L82) Function to extract the key from result items If not provided, defaults to using the key from the D2 stream @@ -97,7 +97,7 @@ If not provided, defaults to using the key from the D2 stream optional id: string; ``` -Defined in: [packages/db/src/query/live/types.ts:63](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L63) +Defined in: [packages/db/src/query/live/types.ts:67](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L67) Unique identifier for the collection If not provided, defaults to `live-query-${number}` with auto-incrementing number @@ -110,7 +110,7 @@ If not provided, defaults to `live-query-${number}` with auto-incrementing numbe optional onDelete: DeleteMutationFn; ``` -Defined in: [packages/db/src/query/live/types.ts:88](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L88) +Defined in: [packages/db/src/query/live/types.ts:94](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L94) *** @@ -120,7 +120,7 @@ Defined in: [packages/db/src/query/live/types.ts:88](https://github.com/TanStack optional onInsert: InsertMutationFn; ``` -Defined in: [packages/db/src/query/live/types.ts:86](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L86) +Defined in: [packages/db/src/query/live/types.ts:92](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L92) Optional mutation handlers @@ -132,7 +132,7 @@ Optional mutation handlers optional onUpdate: UpdateMutationFn; ``` -Defined in: [packages/db/src/query/live/types.ts:87](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L87) +Defined in: [packages/db/src/query/live/types.ts:93](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L93) *** @@ -140,11 +140,11 @@ Defined in: [packages/db/src/query/live/types.ts:87](https://github.com/TanStack ```ts query: - | QueryBuilder -| (q) => QueryBuilder; + | (q) => QueryBuilder & RootObjectResultConstraint +| QueryBuilder & RootObjectResultConstraint; ``` -Defined in: [packages/db/src/query/live/types.ts:68](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L68) +Defined in: [packages/db/src/query/live/types.ts:72](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L72) Query builder function that defines the live query @@ -156,7 +156,7 @@ Query builder function that defines the live query optional schema: undefined; ``` -Defined in: [packages/db/src/query/live/types.ts:81](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L81) +Defined in: [packages/db/src/query/live/types.ts:87](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L87) Optional schema for validation @@ -168,7 +168,7 @@ Optional schema for validation optional singleResult: true; ``` -Defined in: [packages/db/src/query/live/types.ts:103](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L103) +Defined in: [packages/db/src/query/live/types.ts:109](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L109) If enabled the collection will return a single object instead of an array @@ -180,6 +180,6 @@ If enabled the collection will return a single object instead of an array optional startSync: boolean; ``` -Defined in: [packages/db/src/query/live/types.ts:93](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L93) +Defined in: [packages/db/src/query/live/types.ts:99](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/types.ts#L99) Start sync / the query immediately diff --git a/docs/reference/interfaces/LocalOnlyCollectionConfig.md b/docs/reference/interfaces/LocalOnlyCollectionConfig.md index fd67172ed..e948a015e 100644 --- a/docs/reference/interfaces/LocalOnlyCollectionConfig.md +++ b/docs/reference/interfaces/LocalOnlyCollectionConfig.md @@ -41,7 +41,7 @@ The type of the key returned by `getKey` optional autoIndex: "off" | "eager"; ``` -Defined in: [packages/db/src/types.ts:548](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L548) +Defined in: [packages/db/src/types.ts:571](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L571) Auto-indexing mode for the collection. When enabled, indexes will be automatically created for simple where expressions. @@ -49,13 +49,14 @@ When enabled, indexes will be automatically created for simple where expressions #### Default ```ts -"eager" +"off" ``` #### Description -- "off": No automatic indexing -- "eager": Automatically create indexes for simple where expressions in subscribeChanges (default) +- "off": No automatic indexing (default). Use explicit indexes for better bundle size. +- "eager": Automatically create indexes for simple where expressions in subscribeChanges. + Requires setting defaultIndexType. #### Inherited from @@ -69,7 +70,7 @@ When enabled, indexes will be automatically created for simple where expressions optional compare: (x, y) => number; ``` -Defined in: [packages/db/src/types.ts:559](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L559) +Defined in: [packages/db/src/types.ts:596](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L596) Optional function to compare two items. This is used to order the items in the collection. @@ -109,13 +110,43 @@ Omit.compare *** +### defaultIndexType? + +```ts +optional defaultIndexType: IndexConstructor; +``` + +Defined in: [packages/db/src/types.ts:585](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L585) + +Default index type to use when creating indexes without an explicit type. +Required for auto-indexing. Import from '@tanstack/db'. + +#### Example + +```ts +import { BasicIndex } from '@tanstack/db' +const collection = createCollection({ + defaultIndexType: BasicIndex, + autoIndex: 'eager', + // ... +}) +``` + +#### Inherited from + +```ts +Omit.defaultIndexType +``` + +*** + ### defaultStringCollation? ```ts optional defaultStringCollation: StringCollationConfig; ``` -Defined in: [packages/db/src/types.ts:705](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L705) +Defined in: [packages/db/src/types.ts:742](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L742) Specifies how to compare data in the collection. This should be configured to match data ordering on the backend. @@ -136,7 +167,7 @@ Omit.defaultStringCollation getKey: (item) => TKey; ``` -Defined in: [packages/db/src/types.ts:523](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L523) +Defined in: [packages/db/src/types.ts:545](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L545) Function to extract the ID from an object This is required for update/delete operations which now only accept IDs @@ -176,7 +207,7 @@ Omit.getKey optional id: string; ``` -Defined in: [packages/db/src/types.ts:512](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L512) +Defined in: [packages/db/src/types.ts:534](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L534) #### Inherited from @@ -203,7 +234,7 @@ This data will be applied during the initial sync process optional onDelete: DeleteMutationFn; ``` -Defined in: [packages/db/src/types.ts:697](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L697) +Defined in: [packages/db/src/types.ts:734](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L734) Optional asynchronous handler function called before a delete operation @@ -273,7 +304,7 @@ Omit.onDelete optional onInsert: InsertMutationFn; ``` -Defined in: [packages/db/src/types.ts:610](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L610) +Defined in: [packages/db/src/types.ts:647](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L647) Optional asynchronous handler function called before an insert operation @@ -342,7 +373,7 @@ Omit.onInsert optional onUpdate: UpdateMutationFn; ``` -Defined in: [packages/db/src/types.ts:654](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L654) +Defined in: [packages/db/src/types.ts:691](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L691) Optional asynchronous handler function called before an update operation @@ -412,7 +443,7 @@ Omit.onUpdate optional schema: TSchema; ``` -Defined in: [packages/db/src/types.ts:513](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L513) +Defined in: [packages/db/src/types.ts:535](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L535) #### Inherited from @@ -428,7 +459,7 @@ Omit.schema optional syncMode: SyncMode; ``` -Defined in: [packages/db/src/types.ts:568](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L568) +Defined in: [packages/db/src/types.ts:605](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L605) The mode of sync to use for the collection. @@ -454,7 +485,7 @@ The exact implementation of the sync mode is up to the sync implementation. optional utils: LocalOnlyCollectionUtils; ``` -Defined in: [packages/db/src/types.ts:707](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L707) +Defined in: [packages/db/src/types.ts:744](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L744) #### Inherited from diff --git a/docs/reference/interfaces/LocalStorageCollectionConfig.md b/docs/reference/interfaces/LocalStorageCollectionConfig.md index 5137b034e..f6884ecef 100644 --- a/docs/reference/interfaces/LocalStorageCollectionConfig.md +++ b/docs/reference/interfaces/LocalStorageCollectionConfig.md @@ -41,7 +41,7 @@ The type of the key returned by `getKey` optional autoIndex: "off" | "eager"; ``` -Defined in: [packages/db/src/types.ts:548](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L548) +Defined in: [packages/db/src/types.ts:571](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L571) Auto-indexing mode for the collection. When enabled, indexes will be automatically created for simple where expressions. @@ -49,13 +49,14 @@ When enabled, indexes will be automatically created for simple where expressions #### Default ```ts -"eager" +"off" ``` #### Description -- "off": No automatic indexing -- "eager": Automatically create indexes for simple where expressions in subscribeChanges (default) +- "off": No automatic indexing (default). Use explicit indexes for better bundle size. +- "eager": Automatically create indexes for simple where expressions in subscribeChanges. + Requires setting defaultIndexType. #### Inherited from @@ -69,7 +70,7 @@ When enabled, indexes will be automatically created for simple where expressions optional compare: (x, y) => number; ``` -Defined in: [packages/db/src/types.ts:559](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L559) +Defined in: [packages/db/src/types.ts:596](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L596) Optional function to compare two items. This is used to order the items in the collection. @@ -107,13 +108,41 @@ compare: (x, y) => x.createdAt.getTime() - y.createdAt.getTime() *** +### defaultIndexType? + +```ts +optional defaultIndexType: IndexConstructor; +``` + +Defined in: [packages/db/src/types.ts:585](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L585) + +Default index type to use when creating indexes without an explicit type. +Required for auto-indexing. Import from '@tanstack/db'. + +#### Example + +```ts +import { BasicIndex } from '@tanstack/db' +const collection = createCollection({ + defaultIndexType: BasicIndex, + autoIndex: 'eager', + // ... +}) +``` + +#### Inherited from + +[`BaseCollectionConfig`](BaseCollectionConfig.md).[`defaultIndexType`](BaseCollectionConfig.md#defaultindextype) + +*** + ### defaultStringCollation? ```ts optional defaultStringCollation: StringCollationConfig; ``` -Defined in: [packages/db/src/types.ts:705](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L705) +Defined in: [packages/db/src/types.ts:742](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L742) Specifies how to compare data in the collection. This should be configured to match data ordering on the backend. @@ -132,7 +161,7 @@ E.g., when using the Electric DB collection these options optional gcTime: number; ``` -Defined in: [packages/db/src/types.ts:528](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L528) +Defined in: [packages/db/src/types.ts:550](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L550) Time in milliseconds after which the collection will be garbage collected when it has no active subscribers. Defaults to 5 minutes (300000ms). @@ -149,7 +178,7 @@ when it has no active subscribers. Defaults to 5 minutes (300000ms). getKey: (item) => TKey; ``` -Defined in: [packages/db/src/types.ts:523](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L523) +Defined in: [packages/db/src/types.ts:545](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L545) Function to extract the ID from an object This is required for update/delete operations which now only accept IDs @@ -187,7 +216,7 @@ getKey: (item) => item.uuid optional id: string; ``` -Defined in: [packages/db/src/types.ts:512](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L512) +Defined in: [packages/db/src/types.ts:534](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L534) #### Inherited from @@ -201,7 +230,7 @@ Defined in: [packages/db/src/types.ts:512](https://github.com/TanStack/db/blob/m optional onDelete: DeleteMutationFn; ``` -Defined in: [packages/db/src/types.ts:697](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L697) +Defined in: [packages/db/src/types.ts:734](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L734) Optional asynchronous handler function called before a delete operation @@ -269,7 +298,7 @@ onDelete: async ({ transaction, collection }) => { optional onInsert: InsertMutationFn; ``` -Defined in: [packages/db/src/types.ts:610](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L610) +Defined in: [packages/db/src/types.ts:647](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L647) Optional asynchronous handler function called before an insert operation @@ -336,7 +365,7 @@ onInsert: async ({ transaction, collection }) => { optional onUpdate: UpdateMutationFn; ``` -Defined in: [packages/db/src/types.ts:654](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L654) +Defined in: [packages/db/src/types.ts:691](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L691) Optional asynchronous handler function called before an update operation @@ -417,7 +446,7 @@ Defaults to JSON optional schema: TSchema; ``` -Defined in: [packages/db/src/types.ts:513](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L513) +Defined in: [packages/db/src/types.ts:535](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L535) #### Inherited from @@ -431,7 +460,7 @@ Defined in: [packages/db/src/types.ts:513](https://github.com/TanStack/db/blob/m optional startSync: boolean; ``` -Defined in: [packages/db/src/types.ts:539](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L539) +Defined in: [packages/db/src/types.ts:561](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L561) Whether to eagerly start syncing on collection creation. When true, syncing begins immediately. When false, syncing starts when the first subscriber attaches. @@ -496,7 +525,7 @@ The key to use for storing the collection data in localStorage/sessionStorage optional syncMode: SyncMode; ``` -Defined in: [packages/db/src/types.ts:568](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L568) +Defined in: [packages/db/src/types.ts:605](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L605) The mode of sync to use for the collection. @@ -522,7 +551,7 @@ The exact implementation of the sync mode is up to the sync implementation. optional utils: UtilsRecord; ``` -Defined in: [packages/db/src/types.ts:707](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L707) +Defined in: [packages/db/src/types.ts:744](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L744) #### Inherited from diff --git a/docs/reference/interfaces/OperationConfig.md b/docs/reference/interfaces/OperationConfig.md index 260bb3660..3526e49cc 100644 --- a/docs/reference/interfaces/OperationConfig.md +++ b/docs/reference/interfaces/OperationConfig.md @@ -5,7 +5,7 @@ title: OperationConfig # Interface: OperationConfig -Defined in: [packages/db/src/types.ts:411](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L411) +Defined in: [packages/db/src/types.ts:433](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L433) ## Properties @@ -15,7 +15,7 @@ Defined in: [packages/db/src/types.ts:411](https://github.com/TanStack/db/blob/m optional metadata: Record; ``` -Defined in: [packages/db/src/types.ts:412](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L412) +Defined in: [packages/db/src/types.ts:434](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L434) *** @@ -25,6 +25,6 @@ Defined in: [packages/db/src/types.ts:412](https://github.com/TanStack/db/blob/m optional optimistic: boolean; ``` -Defined in: [packages/db/src/types.ts:414](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L414) +Defined in: [packages/db/src/types.ts:436](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L436) Whether to apply optimistic updates immediately. Defaults to true. diff --git a/docs/reference/interfaces/PendingMutation.md b/docs/reference/interfaces/PendingMutation.md index d6cc2b7c8..ac9189a58 100644 --- a/docs/reference/interfaces/PendingMutation.md +++ b/docs/reference/interfaces/PendingMutation.md @@ -5,7 +5,7 @@ title: PendingMutation # Interface: PendingMutation\ -Defined in: [packages/db/src/types.ts:89](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L89) +Defined in: [packages/db/src/types.ts:91](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L91) Represents a pending mutation within a transaction Contains information about the original and modified data, as well as metadata @@ -32,7 +32,7 @@ Contains information about the original and modified data, as well as metadata changes: ResolveTransactionChanges; ``` -Defined in: [packages/db/src/types.ts:106](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L106) +Defined in: [packages/db/src/types.ts:108](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L108) *** @@ -42,7 +42,7 @@ Defined in: [packages/db/src/types.ts:106](https://github.com/TanStack/db/blob/m collection: TCollection; ``` -Defined in: [packages/db/src/types.ts:117](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L117) +Defined in: [packages/db/src/types.ts:119](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L119) *** @@ -52,7 +52,7 @@ Defined in: [packages/db/src/types.ts:117](https://github.com/TanStack/db/blob/m createdAt: Date; ``` -Defined in: [packages/db/src/types.ts:115](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L115) +Defined in: [packages/db/src/types.ts:117](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L117) *** @@ -62,7 +62,7 @@ Defined in: [packages/db/src/types.ts:115](https://github.com/TanStack/db/blob/m globalKey: string; ``` -Defined in: [packages/db/src/types.ts:107](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L107) +Defined in: [packages/db/src/types.ts:109](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L109) *** @@ -72,7 +72,7 @@ Defined in: [packages/db/src/types.ts:107](https://github.com/TanStack/db/blob/m key: any; ``` -Defined in: [packages/db/src/types.ts:109](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L109) +Defined in: [packages/db/src/types.ts:111](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L111) *** @@ -82,7 +82,7 @@ Defined in: [packages/db/src/types.ts:109](https://github.com/TanStack/db/blob/m metadata: unknown; ``` -Defined in: [packages/db/src/types.ts:111](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L111) +Defined in: [packages/db/src/types.ts:113](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L113) *** @@ -92,7 +92,7 @@ Defined in: [packages/db/src/types.ts:111](https://github.com/TanStack/db/blob/m modified: T; ``` -Defined in: [packages/db/src/types.ts:104](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L104) +Defined in: [packages/db/src/types.ts:106](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L106) *** @@ -102,7 +102,7 @@ Defined in: [packages/db/src/types.ts:104](https://github.com/TanStack/db/blob/m mutationId: string; ``` -Defined in: [packages/db/src/types.ts:100](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L100) +Defined in: [packages/db/src/types.ts:102](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L102) *** @@ -112,7 +112,7 @@ Defined in: [packages/db/src/types.ts:100](https://github.com/TanStack/db/blob/m optimistic: boolean; ``` -Defined in: [packages/db/src/types.ts:114](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L114) +Defined in: [packages/db/src/types.ts:116](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L116) Whether this mutation should be applied optimistically (defaults to true) @@ -124,7 +124,7 @@ Whether this mutation should be applied optimistically (defaults to true) original: TOperation extends "insert" ? object : T; ``` -Defined in: [packages/db/src/types.ts:102](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L102) +Defined in: [packages/db/src/types.ts:104](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L104) *** @@ -134,7 +134,7 @@ Defined in: [packages/db/src/types.ts:102](https://github.com/TanStack/db/blob/m syncMetadata: Record; ``` -Defined in: [packages/db/src/types.ts:112](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L112) +Defined in: [packages/db/src/types.ts:114](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L114) *** @@ -144,7 +144,7 @@ Defined in: [packages/db/src/types.ts:112](https://github.com/TanStack/db/blob/m type: TOperation; ``` -Defined in: [packages/db/src/types.ts:110](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L110) +Defined in: [packages/db/src/types.ts:112](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L112) *** @@ -154,4 +154,4 @@ Defined in: [packages/db/src/types.ts:110](https://github.com/TanStack/db/blob/m updatedAt: Date; ``` -Defined in: [packages/db/src/types.ts:116](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L116) +Defined in: [packages/db/src/types.ts:118](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L118) diff --git a/docs/reference/interfaces/QueryOnceConfig.md b/docs/reference/interfaces/QueryOnceConfig.md index 1286022d2..23a9150dc 100644 --- a/docs/reference/interfaces/QueryOnceConfig.md +++ b/docs/reference/interfaces/QueryOnceConfig.md @@ -5,7 +5,7 @@ title: QueryOnceConfig # Interface: QueryOnceConfig\ -Defined in: [packages/db/src/query/query-once.ts:8](https://github.com/TanStack/db/blob/main/packages/db/src/query/query-once.ts#L8) +Defined in: [packages/db/src/query/query-once.ts:18](https://github.com/TanStack/db/blob/main/packages/db/src/query/query-once.ts#L18) Configuration options for queryOnce @@ -21,10 +21,10 @@ Configuration options for queryOnce ```ts query: - | QueryBuilder -| (q) => QueryBuilder; + | (q) => QueryBuilder & RootObjectResultConstraint +| QueryBuilder & RootObjectResultConstraint; ``` -Defined in: [packages/db/src/query/query-once.ts:12](https://github.com/TanStack/db/blob/main/packages/db/src/query/query-once.ts#L12) +Defined in: [packages/db/src/query/query-once.ts:22](https://github.com/TanStack/db/blob/main/packages/db/src/query/query-once.ts#L22) Query builder function that defines the query diff --git a/docs/reference/interfaces/RangeQueryOptions.md b/docs/reference/interfaces/RangeQueryOptions.md index 3a4d06cfb..204e822ba 100644 --- a/docs/reference/interfaces/RangeQueryOptions.md +++ b/docs/reference/interfaces/RangeQueryOptions.md @@ -5,7 +5,7 @@ title: RangeQueryOptions # Interface: RangeQueryOptions -Defined in: [packages/db/src/indexes/btree-index.ts:24](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L24) +Defined in: [packages/db/src/indexes/basic-index.ts:14](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L14) Options for range queries @@ -17,7 +17,7 @@ Options for range queries optional from: any; ``` -Defined in: [packages/db/src/indexes/btree-index.ts:25](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L25) +Defined in: [packages/db/src/indexes/basic-index.ts:15](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L15) *** @@ -27,7 +27,7 @@ Defined in: [packages/db/src/indexes/btree-index.ts:25](https://github.com/TanSt optional fromInclusive: boolean; ``` -Defined in: [packages/db/src/indexes/btree-index.ts:27](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L27) +Defined in: [packages/db/src/indexes/basic-index.ts:17](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L17) *** @@ -37,7 +37,7 @@ Defined in: [packages/db/src/indexes/btree-index.ts:27](https://github.com/TanSt optional to: any; ``` -Defined in: [packages/db/src/indexes/btree-index.ts:26](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L26) +Defined in: [packages/db/src/indexes/basic-index.ts:16](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L16) *** @@ -47,4 +47,4 @@ Defined in: [packages/db/src/indexes/btree-index.ts:26](https://github.com/TanSt optional toInclusive: boolean; ``` -Defined in: [packages/db/src/indexes/btree-index.ts:28](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/btree-index.ts#L28) +Defined in: [packages/db/src/indexes/basic-index.ts:18](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/basic-index.ts#L18) diff --git a/docs/reference/interfaces/SubscribeChangesOptions.md b/docs/reference/interfaces/SubscribeChangesOptions.md index 8bb0d7d83..a981f4460 100644 --- a/docs/reference/interfaces/SubscribeChangesOptions.md +++ b/docs/reference/interfaces/SubscribeChangesOptions.md @@ -3,9 +3,9 @@ id: SubscribeChangesOptions title: SubscribeChangesOptions --- -# Interface: SubscribeChangesOptions\ +# Interface: SubscribeChangesOptions\ -Defined in: [packages/db/src/types.ts:784](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L784) +Defined in: [packages/db/src/types.ts:822](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L822) Options for subscribing to collection changes @@ -15,6 +15,10 @@ Options for subscribing to collection changes `T` *extends* `object` = `Record`\<`string`, `unknown`\> +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + ## Properties ### includeInitialState? @@ -23,7 +27,7 @@ Options for subscribing to collection changes optional includeInitialState: boolean; ``` -Defined in: [packages/db/src/types.ts:788](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L788) +Defined in: [packages/db/src/types.ts:827](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L827) Whether to include the current state as initial changes @@ -35,7 +39,7 @@ Whether to include the current state as initial changes optional limit: number; ``` -Defined in: [packages/db/src/types.ts:821](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L821) +Defined in: [packages/db/src/types.ts:860](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L860) **`Internal`** @@ -49,7 +53,7 @@ Optional limit to include in loadSubset for query-specific cache keys. optional onLoadSubsetResult: (result) => void; ``` -Defined in: [packages/db/src/types.ts:827](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L827) +Defined in: [packages/db/src/types.ts:866](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L866) **`Internal`** @@ -74,7 +78,7 @@ Allows the caller to directly track the loading promise for isReady status. optional onStatusChange: (event) => void; ``` -Defined in: [packages/db/src/types.ts:811](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L811) +Defined in: [packages/db/src/types.ts:850](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L850) **`Internal`** @@ -99,7 +103,7 @@ Registered BEFORE any snapshot is requested, ensuring no status transitions are optional orderBy: OrderBy; ``` -Defined in: [packages/db/src/types.ts:816](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L816) +Defined in: [packages/db/src/types.ts:855](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L855) **`Internal`** @@ -113,7 +117,7 @@ Optional orderBy to include in loadSubset for query-specific cache keys. optional where: (row) => any; ``` -Defined in: [packages/db/src/types.ts:803](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L803) +Defined in: [packages/db/src/types.ts:842](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L842) Callback function for filtering changes using a row proxy. The callback receives a proxy object that records property access, @@ -123,7 +127,7 @@ allowing you to use query builder functions like `eq`, `gt`, etc. ##### row -`SingleRowRefProxy`\<`T`\> +`SingleRowRefProxy`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>\> #### Returns @@ -147,6 +151,6 @@ collection.subscribeChanges(callback, { optional whereExpression: BasicExpression; ``` -Defined in: [packages/db/src/types.ts:805](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L805) +Defined in: [packages/db/src/types.ts:844](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L844) Pre-compiled expression for filtering changes diff --git a/docs/reference/interfaces/SubscribeChangesSnapshotOptions.md b/docs/reference/interfaces/SubscribeChangesSnapshotOptions.md index bb7218ba5..f60351b33 100644 --- a/docs/reference/interfaces/SubscribeChangesSnapshotOptions.md +++ b/docs/reference/interfaces/SubscribeChangesSnapshotOptions.md @@ -3,13 +3,13 @@ id: SubscribeChangesSnapshotOptions title: SubscribeChangesSnapshotOptions --- -# Interface: SubscribeChangesSnapshotOptions\ +# Interface: SubscribeChangesSnapshotOptions\ -Defined in: [packages/db/src/types.ts:830](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L830) +Defined in: [packages/db/src/types.ts:869](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L869) ## Extends -- `Omit`\<[`SubscribeChangesOptions`](SubscribeChangesOptions.md)\<`T`\>, `"includeInitialState"`\> +- `Omit`\<[`SubscribeChangesOptions`](SubscribeChangesOptions.md)\<`T`, `TKey`\>, `"includeInitialState"`\> ## Type Parameters @@ -17,6 +17,10 @@ Defined in: [packages/db/src/types.ts:830](https://github.com/TanStack/db/blob/m `T` *extends* `object` = `Record`\<`string`, `unknown`\> +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + ## Properties ### limit? @@ -25,7 +29,7 @@ Defined in: [packages/db/src/types.ts:830](https://github.com/TanStack/db/blob/m optional limit: number; ``` -Defined in: [packages/db/src/types.ts:834](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L834) +Defined in: [packages/db/src/types.ts:874](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L874) **`Internal`** @@ -33,9 +37,7 @@ Optional limit to include in loadSubset for query-specific cache keys. #### Overrides -```ts -Omit.limit -``` +[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`limit`](SubscribeChangesOptions.md#limit) *** @@ -45,7 +47,7 @@ Omit.limit optional onLoadSubsetResult: (result) => void; ``` -Defined in: [packages/db/src/types.ts:827](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L827) +Defined in: [packages/db/src/types.ts:866](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L866) **`Internal`** @@ -76,7 +78,7 @@ Omit.onLoadSubsetResult optional onStatusChange: (event) => void; ``` -Defined in: [packages/db/src/types.ts:811](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L811) +Defined in: [packages/db/src/types.ts:850](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L850) **`Internal`** @@ -107,7 +109,7 @@ Omit.onStatusChange optional orderBy: OrderBy; ``` -Defined in: [packages/db/src/types.ts:833](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L833) +Defined in: [packages/db/src/types.ts:873](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L873) **`Internal`** @@ -115,9 +117,7 @@ Optional orderBy to include in loadSubset for query-specific cache keys. #### Overrides -```ts -Omit.orderBy -``` +[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`orderBy`](SubscribeChangesOptions.md#orderby) *** @@ -127,7 +127,7 @@ Omit.orderBy optional where: (row) => any; ``` -Defined in: [packages/db/src/types.ts:803](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L803) +Defined in: [packages/db/src/types.ts:842](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L842) Callback function for filtering changes using a row proxy. The callback receives a proxy object that records property access, @@ -137,7 +137,7 @@ allowing you to use query builder functions like `eq`, `gt`, etc. ##### row -`SingleRowRefProxy`\<`T`\> +`SingleRowRefProxy`\<[`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>\> #### Returns @@ -167,12 +167,10 @@ Omit.where optional whereExpression: BasicExpression; ``` -Defined in: [packages/db/src/types.ts:805](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L805) +Defined in: [packages/db/src/types.ts:844](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L844) Pre-compiled expression for filtering changes #### Inherited from -```ts -Omit.whereExpression -``` +[`SubscribeChangesOptions`](SubscribeChangesOptions.md).[`whereExpression`](SubscribeChangesOptions.md#whereexpression) diff --git a/docs/reference/interfaces/Subscription.md b/docs/reference/interfaces/Subscription.md index 0aa55abe0..b3ff2b667 100644 --- a/docs/reference/interfaces/Subscription.md +++ b/docs/reference/interfaces/Subscription.md @@ -5,7 +5,7 @@ title: Subscription # Interface: Subscription -Defined in: [packages/db/src/types.ts:252](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L252) +Defined in: [packages/db/src/types.ts:254](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L254) Public interface for a collection subscription Used by sync implementations to track subscription lifecycle @@ -22,7 +22,7 @@ Used by sync implementations to track subscription lifecycle readonly status: SubscriptionStatus; ``` -Defined in: [packages/db/src/types.ts:254](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L254) +Defined in: [packages/db/src/types.ts:256](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L256) Current status of the subscription diff --git a/docs/reference/interfaces/SubscriptionStatusChangeEvent.md b/docs/reference/interfaces/SubscriptionStatusChangeEvent.md index ed2298b09..87c7e584a 100644 --- a/docs/reference/interfaces/SubscriptionStatusChangeEvent.md +++ b/docs/reference/interfaces/SubscriptionStatusChangeEvent.md @@ -5,7 +5,7 @@ title: SubscriptionStatusChangeEvent # Interface: SubscriptionStatusChangeEvent -Defined in: [packages/db/src/types.ts:213](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L213) +Defined in: [packages/db/src/types.ts:215](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L215) Event emitted when subscription status changes @@ -17,7 +17,7 @@ Event emitted when subscription status changes previousStatus: SubscriptionStatus; ``` -Defined in: [packages/db/src/types.ts:216](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L216) +Defined in: [packages/db/src/types.ts:218](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L218) *** @@ -27,7 +27,7 @@ Defined in: [packages/db/src/types.ts:216](https://github.com/TanStack/db/blob/m status: SubscriptionStatus; ``` -Defined in: [packages/db/src/types.ts:217](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L217) +Defined in: [packages/db/src/types.ts:219](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L219) *** @@ -37,7 +37,7 @@ Defined in: [packages/db/src/types.ts:217](https://github.com/TanStack/db/blob/m subscription: Subscription; ``` -Defined in: [packages/db/src/types.ts:215](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L215) +Defined in: [packages/db/src/types.ts:217](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L217) *** @@ -47,4 +47,4 @@ Defined in: [packages/db/src/types.ts:215](https://github.com/TanStack/db/blob/m type: "status:change"; ``` -Defined in: [packages/db/src/types.ts:214](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L214) +Defined in: [packages/db/src/types.ts:216](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L216) diff --git a/docs/reference/interfaces/SubscriptionStatusEvent.md b/docs/reference/interfaces/SubscriptionStatusEvent.md index 0d55a134d..5a3aee984 100644 --- a/docs/reference/interfaces/SubscriptionStatusEvent.md +++ b/docs/reference/interfaces/SubscriptionStatusEvent.md @@ -5,7 +5,7 @@ title: SubscriptionStatusEvent # Interface: SubscriptionStatusEvent\ -Defined in: [packages/db/src/types.ts:223](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L223) +Defined in: [packages/db/src/types.ts:225](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L225) Event emitted when subscription status changes to a specific status @@ -23,7 +23,7 @@ Event emitted when subscription status changes to a specific status previousStatus: SubscriptionStatus; ``` -Defined in: [packages/db/src/types.ts:226](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L226) +Defined in: [packages/db/src/types.ts:228](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L228) *** @@ -33,7 +33,7 @@ Defined in: [packages/db/src/types.ts:226](https://github.com/TanStack/db/blob/m status: T; ``` -Defined in: [packages/db/src/types.ts:227](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L227) +Defined in: [packages/db/src/types.ts:229](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L229) *** @@ -43,7 +43,7 @@ Defined in: [packages/db/src/types.ts:227](https://github.com/TanStack/db/blob/m subscription: Subscription; ``` -Defined in: [packages/db/src/types.ts:225](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L225) +Defined in: [packages/db/src/types.ts:227](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L227) *** @@ -53,4 +53,4 @@ Defined in: [packages/db/src/types.ts:225](https://github.com/TanStack/db/blob/m type: `status:${T}`; ``` -Defined in: [packages/db/src/types.ts:224](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L224) +Defined in: [packages/db/src/types.ts:226](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L226) diff --git a/docs/reference/interfaces/SubscriptionUnsubscribedEvent.md b/docs/reference/interfaces/SubscriptionUnsubscribedEvent.md index 6eea86fa2..a62ce55f6 100644 --- a/docs/reference/interfaces/SubscriptionUnsubscribedEvent.md +++ b/docs/reference/interfaces/SubscriptionUnsubscribedEvent.md @@ -5,7 +5,7 @@ title: SubscriptionUnsubscribedEvent # Interface: SubscriptionUnsubscribedEvent -Defined in: [packages/db/src/types.ts:233](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L233) +Defined in: [packages/db/src/types.ts:235](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L235) Event emitted when subscription is unsubscribed @@ -17,7 +17,7 @@ Event emitted when subscription is unsubscribed subscription: Subscription; ``` -Defined in: [packages/db/src/types.ts:235](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L235) +Defined in: [packages/db/src/types.ts:237](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L237) *** @@ -27,4 +27,4 @@ Defined in: [packages/db/src/types.ts:235](https://github.com/TanStack/db/blob/m type: "unsubscribed"; ``` -Defined in: [packages/db/src/types.ts:234](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L234) +Defined in: [packages/db/src/types.ts:236](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L236) diff --git a/docs/reference/interfaces/SyncConfig.md b/docs/reference/interfaces/SyncConfig.md index 2ac2c3230..adc0e4bb1 100644 --- a/docs/reference/interfaces/SyncConfig.md +++ b/docs/reference/interfaces/SyncConfig.md @@ -5,7 +5,7 @@ title: SyncConfig # Interface: SyncConfig\ -Defined in: [packages/db/src/types.ts:325](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L325) +Defined in: [packages/db/src/types.ts:327](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L327) ## Type Parameters @@ -25,7 +25,7 @@ Defined in: [packages/db/src/types.ts:325](https://github.com/TanStack/db/blob/m optional getSyncMetadata: () => Record; ``` -Defined in: [packages/db/src/types.ts:347](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L347) +Defined in: [packages/db/src/types.ts:350](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L350) Get the sync metadata for insert operations @@ -43,7 +43,7 @@ Record containing relation information optional rowUpdateMode: "full" | "partial"; ``` -Defined in: [packages/db/src/types.ts:356](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L356) +Defined in: [packages/db/src/types.ts:359](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L359) The row update mode used to sync to the collection. @@ -67,7 +67,7 @@ sync: (params) => | SyncConfigRes; ``` -Defined in: [packages/db/src/types.ts:329](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L329) +Defined in: [packages/db/src/types.ts:331](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L331) #### Parameters @@ -91,6 +91,10 @@ Begin a new sync transaction. () => `void` +###### metadata? + +[`SyncMetadataApi`](SyncMetadataApi.md)\<`TKey`\> + ###### truncate () => `void` diff --git a/docs/reference/interfaces/SyncMetadataApi.md b/docs/reference/interfaces/SyncMetadataApi.md new file mode 100644 index 000000000..15d6787dc --- /dev/null +++ b/docs/reference/interfaces/SyncMetadataApi.md @@ -0,0 +1,154 @@ +--- +id: SyncMetadataApi +title: SyncMetadataApi +--- + +# Interface: SyncMetadataApi\ + +Defined in: [packages/db/src/types.ts:362](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L362) + +## Type Parameters + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + +## Properties + +### collection + +```ts +collection: object; +``` + +Defined in: [packages/db/src/types.ts:370](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L370) + +#### delete() + +```ts +delete: (key) => void; +``` + +##### Parameters + +###### key + +`string` + +##### Returns + +`void` + +#### get() + +```ts +get: (key) => unknown; +``` + +##### Parameters + +###### key + +`string` + +##### Returns + +`unknown` + +#### list() + +```ts +list: (prefix?) => readonly object[]; +``` + +##### Parameters + +###### prefix? + +`string` + +##### Returns + +readonly `object`[] + +#### set() + +```ts +set: (key, value) => void; +``` + +##### Parameters + +###### key + +`string` + +###### value + +`unknown` + +##### Returns + +`void` + +*** + +### row + +```ts +row: object; +``` + +Defined in: [packages/db/src/types.ts:365](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L365) + +#### delete() + +```ts +delete: (key) => void; +``` + +##### Parameters + +###### key + +`TKey` + +##### Returns + +`void` + +#### get() + +```ts +get: (key) => unknown; +``` + +##### Parameters + +###### key + +`TKey` + +##### Returns + +`unknown` + +#### set() + +```ts +set: (key, metadata) => void; +``` + +##### Parameters + +###### key + +`TKey` + +###### metadata + +`unknown` + +##### Returns + +`void` diff --git a/docs/reference/interfaces/TransactionConfig.md b/docs/reference/interfaces/TransactionConfig.md index ae5f413e9..c146f2f11 100644 --- a/docs/reference/interfaces/TransactionConfig.md +++ b/docs/reference/interfaces/TransactionConfig.md @@ -5,7 +5,7 @@ title: TransactionConfig # Interface: TransactionConfig\ -Defined in: [packages/db/src/types.ts:166](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L166) +Defined in: [packages/db/src/types.ts:168](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L168) ## Type Parameters @@ -21,7 +21,7 @@ Defined in: [packages/db/src/types.ts:166](https://github.com/TanStack/db/blob/m optional autoCommit: boolean; ``` -Defined in: [packages/db/src/types.ts:170](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L170) +Defined in: [packages/db/src/types.ts:172](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L172) *** @@ -31,7 +31,7 @@ Defined in: [packages/db/src/types.ts:170](https://github.com/TanStack/db/blob/m optional id: string; ``` -Defined in: [packages/db/src/types.ts:168](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L168) +Defined in: [packages/db/src/types.ts:170](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L170) Unique identifier for the transaction @@ -43,7 +43,7 @@ Unique identifier for the transaction optional metadata: Record; ``` -Defined in: [packages/db/src/types.ts:173](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L173) +Defined in: [packages/db/src/types.ts:175](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L175) Custom metadata to associate with the transaction @@ -55,4 +55,4 @@ Custom metadata to associate with the transaction mutationFn: MutationFn; ``` -Defined in: [packages/db/src/types.ts:171](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L171) +Defined in: [packages/db/src/types.ts:173](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L173) diff --git a/docs/reference/interfaces/VirtualRowProps.md b/docs/reference/interfaces/VirtualRowProps.md new file mode 100644 index 000000000..c4719d188 --- /dev/null +++ b/docs/reference/interfaces/VirtualRowProps.md @@ -0,0 +1,112 @@ +--- +id: VirtualRowProps +title: VirtualRowProps +--- + +# Interface: VirtualRowProps\ + +Defined in: [packages/db/src/virtual-props.ts:57](https://github.com/TanStack/db/blob/main/packages/db/src/virtual-props.ts#L57) + +Virtual properties available on every row in TanStack DB collections. + +These properties are: +- Computed (not stored in the data model) +- Read-only (cannot be mutated directly) +- Available in queries (WHERE, ORDER BY, SELECT) +- Included when spreading rows (`...user`) + +## Examples + +```typescript +// Accessing virtual properties on a row +const user = collection.get('user-1') +if (user.$synced) { + console.log('Confirmed by backend') +} +if (user.$origin === 'local') { + console.log('Created/modified locally') +} +``` + +```typescript +// Using virtual properties in queries +const confirmedOrders = createLiveQueryCollection({ + query: (q) => q + .from({ order: orders }) + .where(({ order }) => eq(order.$synced, true)) +}) +``` + +## Type Parameters + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + +The type of the row's key (string or number) + +## Properties + +### $collectionId + +```ts +readonly $collectionId: string; +``` + +Defined in: [packages/db/src/virtual-props.ts:96](https://github.com/TanStack/db/blob/main/packages/db/src/virtual-props.ts#L96) + +The ID of the source collection this row originated from. + +In joins, this can help identify which collection each row came from. +For live query collections, this is the ID of the upstream collection. + +*** + +### $key + +```ts +readonly $key: TKey; +``` + +Defined in: [packages/db/src/virtual-props.ts:88](https://github.com/TanStack/db/blob/main/packages/db/src/virtual-props.ts#L88) + +The row's key (primary identifier). + +This is the same value returned by `collection.config.getKey(row)`. +Useful when you need the key in projections or computations. + +*** + +### $origin + +```ts +readonly $origin: VirtualOrigin; +``` + +Defined in: [packages/db/src/virtual-props.ts:80](https://github.com/TanStack/db/blob/main/packages/db/src/virtual-props.ts#L80) + +Origin of the last confirmed change to this row, from the current client's perspective. + +- `'local'`: The change originated from this client +- `'remote'`: The change was received via sync + +For local-only collections, this is always `'local'`. +For live query collections, this is passed through from the source collection. + +*** + +### $synced + +```ts +readonly $synced: boolean; +``` + +Defined in: [packages/db/src/virtual-props.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/virtual-props.ts#L69) + +Whether this row reflects confirmed state from the backend. + +- `true`: Row is confirmed by the backend (no pending optimistic mutations) +- `false`: Row has pending optimistic mutations that haven't been confirmed + +For local-only collections (no sync), this is always `true`. +For live query collections, this is passed through from the source collection. diff --git a/docs/reference/powersync-db-collection/functions/compileSQLite.md b/docs/reference/powersync-db-collection/functions/compileSQLite.md new file mode 100644 index 000000000..9254ff401 --- /dev/null +++ b/docs/reference/powersync-db-collection/functions/compileSQLite.md @@ -0,0 +1,42 @@ +--- +id: compileSQLite +title: compileSQLite +--- + +# Function: compileSQLite() + +```ts +function compileSQLite(options, compileOptions?): SQLiteCompiledQuery; +``` + +Defined in: [sqlite-compiler.ts:45](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/sqlite-compiler.ts#L45) + +Compiles TanStack DB LoadSubsetOptions to SQLite query components. + +## Parameters + +### options + +`LoadSubsetOptions` + +### compileOptions? + +[`CompileSQLiteOptions`](../interfaces/CompileSQLiteOptions.md) + +## Returns + +[`SQLiteCompiledQuery`](../interfaces/SQLiteCompiledQuery.md) + +## Example + +```typescript +const compiled = compileSQLite({ + where: { type: 'func', name: 'gt', args: [ + { type: 'ref', path: ['price'] }, + { type: 'val', value: 100 } + ]}, + orderBy: [{ expression: { type: 'ref', path: ['price'] }, compareOptions: { direction: 'desc', nulls: 'last' } }], + limit: 50 +}) +// Result: { where: '"price" > ?', orderBy: '"price" DESC', limit: 50, params: [100] } +``` diff --git a/docs/reference/powersync-db-collection/functions/powerSyncCollectionOptions.md b/docs/reference/powersync-db-collection/functions/powerSyncCollectionOptions.md index b40d086f6..ca73a4a4b 100644 --- a/docs/reference/powersync-db-collection/functions/powerSyncCollectionOptions.md +++ b/docs/reference/powersync-db-collection/functions/powerSyncCollectionOptions.md @@ -13,7 +13,7 @@ Implementation of powerSyncCollectionOptions that handles both schema and non-sc function powerSyncCollectionOptions(config): EnhancedPowerSyncCollectionConfig, never>; ``` -Defined in: [powersync.ts:71](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/powersync.ts#L71) +Defined in: [powersync.ts:78](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/powersync.ts#L78) Creates a PowerSync collection configuration with basic default validation. Input and Output types are the SQLite column types. @@ -28,7 +28,7 @@ Input and Output types are the SQLite column types. #### config -`Omit`\<`BaseCollectionConfig`\<`ExtractedTable`\<`TTable`\>, `string`, `never`, `UtilsRecord`, `any`\>, `"onInsert"` \| `"onUpdate"` \| `"onDelete"` \| `"getKey"`\> & `object` +[`BasePowerSyncCollectionConfig`](../type-aliases/BasePowerSyncCollectionConfig.md)\<`TTable`, `never`\> & [`ConfigWithSQLiteTypes`](../type-aliases/ConfigWithSQLiteTypes.md) ### Returns @@ -66,7 +66,7 @@ const collection = createCollection( function powerSyncCollectionOptions(config): CollectionConfig, string, TSchema, PowerSyncCollectionUtils> & object & object; ``` -Defined in: [powersync.ts:128](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/powersync.ts#L128) +Defined in: [powersync.ts:135](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/powersync.ts#L135) Creates a PowerSync collection configuration with schema validation. @@ -92,7 +92,7 @@ serializer specifications. Partial column overrides can be supplied to `serializ #### config -`Omit`\<`BaseCollectionConfig`\<`ExtractedTable`\<`TTable`\>, `string`, `TSchema`, `UtilsRecord`, `any`\>, `"onInsert"` \| `"onUpdate"` \| `"onDelete"` \| `"getKey"`\> & `object` & [`SerializerConfig`](../type-aliases/SerializerConfig.md)\<`InferOutput`\<`TSchema`\>, `ExtractedTable`\<`TTable`\>\> & `object` +[`BasePowerSyncCollectionConfig`](../type-aliases/BasePowerSyncCollectionConfig.md)\<`TTable`, `TSchema`\> & [`SerializerConfig`](../type-aliases/SerializerConfig.md)\<`InferOutput`\<`TSchema`\>, `ExtractedTable`\<`TTable`\>\> & `object` ### Returns @@ -141,7 +141,7 @@ const collection = createCollection( function powerSyncCollectionOptions(config): CollectionConfig, string, TSchema, PowerSyncCollectionUtils> & object & object; ``` -Defined in: [powersync.ts:196](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/powersync.ts#L196) +Defined in: [powersync.ts:203](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/powersync.ts#L203) Creates a PowerSync collection configuration with schema validation. @@ -169,7 +169,7 @@ serializer specifications. Partial column overrides can be supplied to `serializ #### config -`Omit`\<`BaseCollectionConfig`\<`ExtractedTable`\<`TTable`\>, `string`, `TSchema`, `UtilsRecord`, `any`\>, `"onInsert"` \| `"onUpdate"` \| `"onDelete"` \| `"getKey"`\> & `object` & [`SerializerConfig`](../type-aliases/SerializerConfig.md)\<`InferOutput`\<`TSchema`\>, `ExtractedTable`\<`TTable`\>\> & `object` +[`BasePowerSyncCollectionConfig`](../type-aliases/BasePowerSyncCollectionConfig.md)\<`TTable`, `TSchema`\> & [`SerializerConfig`](../type-aliases/SerializerConfig.md)\<`InferOutput`\<`TSchema`\>, `ExtractedTable`\<`TTable`\>\> & `object` ### Returns diff --git a/docs/reference/powersync-db-collection/index.md b/docs/reference/powersync-db-collection/index.md index f6467856d..7be9d9658 100644 --- a/docs/reference/powersync-db-collection/index.md +++ b/docs/reference/powersync-db-collection/index.md @@ -9,6 +9,11 @@ title: "@tanstack/powersync-db-collection" - [PowerSyncTransactor](classes/PowerSyncTransactor.md) +## Interfaces + +- [CompileSQLiteOptions](interfaces/CompileSQLiteOptions.md) +- [SQLiteCompiledQuery](interfaces/SQLiteCompiledQuery.md) + ## Type Aliases - [BasePowerSyncCollectionConfig](type-aliases/BasePowerSyncCollectionConfig.md) @@ -16,8 +21,10 @@ title: "@tanstack/powersync-db-collection" - [ConfigWithSQLiteInputType](type-aliases/ConfigWithSQLiteInputType.md) - [ConfigWithSQLiteTypes](type-aliases/ConfigWithSQLiteTypes.md) - [CustomSQLiteSerializer](type-aliases/CustomSQLiteSerializer.md) +- [EagerSyncHooks](type-aliases/EagerSyncHooks.md) - [EnhancedPowerSyncCollectionConfig](type-aliases/EnhancedPowerSyncCollectionConfig.md) - [InferPowerSyncOutputType](type-aliases/InferPowerSyncOutputType.md) +- [OnDemandSyncHooks](type-aliases/OnDemandSyncHooks.md) - [PowerSyncCollectionConfig](type-aliases/PowerSyncCollectionConfig.md) - [PowerSyncCollectionMeta](type-aliases/PowerSyncCollectionMeta.md) - [PowerSyncCollectionUtils](type-aliases/PowerSyncCollectionUtils.md) @@ -30,4 +37,5 @@ title: "@tanstack/powersync-db-collection" ## Functions +- [compileSQLite](functions/compileSQLite.md) - [powerSyncCollectionOptions](functions/powerSyncCollectionOptions.md) diff --git a/docs/reference/powersync-db-collection/interfaces/CompileSQLiteOptions.md b/docs/reference/powersync-db-collection/interfaces/CompileSQLiteOptions.md new file mode 100644 index 000000000..23f8537ed --- /dev/null +++ b/docs/reference/powersync-db-collection/interfaces/CompileSQLiteOptions.md @@ -0,0 +1,24 @@ +--- +id: CompileSQLiteOptions +title: CompileSQLiteOptions +--- + +# Interface: CompileSQLiteOptions + +Defined in: [sqlite-compiler.ts:20](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/sqlite-compiler.ts#L20) + +Options for controlling how SQL is compiled. + +## Properties + +### jsonColumn? + +```ts +optional jsonColumn: string; +``` + +Defined in: [sqlite-compiler.ts:26](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/sqlite-compiler.ts#L26) + +When set, column references emit `json_extract(, '$.')` +instead of `""`. The `id` column is excluded since it's stored +as a direct column in the tracked table. diff --git a/docs/reference/powersync-db-collection/interfaces/SQLiteCompiledQuery.md b/docs/reference/powersync-db-collection/interfaces/SQLiteCompiledQuery.md new file mode 100644 index 000000000..f7874c7e4 --- /dev/null +++ b/docs/reference/powersync-db-collection/interfaces/SQLiteCompiledQuery.md @@ -0,0 +1,58 @@ +--- +id: SQLiteCompiledQuery +title: SQLiteCompiledQuery +--- + +# Interface: SQLiteCompiledQuery + +Defined in: [sqlite-compiler.ts:6](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/sqlite-compiler.ts#L6) + +Result of compiling LoadSubsetOptions to SQLite + +## Properties + +### limit? + +```ts +optional limit: number; +``` + +Defined in: [sqlite-compiler.ts:12](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/sqlite-compiler.ts#L12) + +The LIMIT value + +*** + +### orderBy? + +```ts +optional orderBy: string; +``` + +Defined in: [sqlite-compiler.ts:10](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/sqlite-compiler.ts#L10) + +The ORDER BY clause (without "ORDER BY" keyword), e.g., "price DESC" + +*** + +### params + +```ts +params: unknown[]; +``` + +Defined in: [sqlite-compiler.ts:14](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/sqlite-compiler.ts#L14) + +Parameter values in order, to be passed to SQLite query + +*** + +### where? + +```ts +optional where: string; +``` + +Defined in: [sqlite-compiler.ts:8](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/sqlite-compiler.ts#L8) + +The WHERE clause (without "WHERE" keyword), e.g., "price > ?" diff --git a/docs/reference/powersync-db-collection/type-aliases/BasePowerSyncCollectionConfig.md b/docs/reference/powersync-db-collection/type-aliases/BasePowerSyncCollectionConfig.md index 4966c6574..7a3b0ddea 100644 --- a/docs/reference/powersync-db-collection/type-aliases/BasePowerSyncCollectionConfig.md +++ b/docs/reference/powersync-db-collection/type-aliases/BasePowerSyncCollectionConfig.md @@ -6,10 +6,12 @@ title: BasePowerSyncCollectionConfig # Type Alias: BasePowerSyncCollectionConfig\ ```ts -type BasePowerSyncCollectionConfig = Omit, string, TSchema>, "onInsert" | "onUpdate" | "onDelete" | "getKey"> & object; +type BasePowerSyncCollectionConfig = Omit, string, TSchema>, "onInsert" | "onUpdate" | "onDelete" | "getKey" | "syncMode"> & object & + | EagerSyncHooks + | OnDemandSyncHooks; ``` -Defined in: [definitions.ts:165](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L165) +Defined in: [definitions.ts:203](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L203) ## Type Declaration diff --git a/docs/reference/powersync-db-collection/type-aliases/ConfigWithArbitraryCollectionTypes.md b/docs/reference/powersync-db-collection/type-aliases/ConfigWithArbitraryCollectionTypes.md index a51250077..bf801bb2a 100644 --- a/docs/reference/powersync-db-collection/type-aliases/ConfigWithArbitraryCollectionTypes.md +++ b/docs/reference/powersync-db-collection/type-aliases/ConfigWithArbitraryCollectionTypes.md @@ -9,7 +9,7 @@ title: ConfigWithArbitraryCollectionTypes type ConfigWithArbitraryCollectionTypes = SerializerConfig, ExtractedTable> & object; ``` -Defined in: [definitions.ts:125](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L125) +Defined in: [definitions.ts:127](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L127) Config where TInput and TOutput have arbitrarily typed values. The keys of the types need to equal the SQLite types. diff --git a/docs/reference/powersync-db-collection/type-aliases/ConfigWithSQLiteInputType.md b/docs/reference/powersync-db-collection/type-aliases/ConfigWithSQLiteInputType.md index 1d58b51a6..169e85646 100644 --- a/docs/reference/powersync-db-collection/type-aliases/ConfigWithSQLiteInputType.md +++ b/docs/reference/powersync-db-collection/type-aliases/ConfigWithSQLiteInputType.md @@ -9,7 +9,7 @@ title: ConfigWithSQLiteInputType type ConfigWithSQLiteInputType = SerializerConfig, ExtractedTable> & object; ``` -Defined in: [definitions.ts:106](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L106) +Defined in: [definitions.ts:108](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L108) Config where TInput is the SQLite types while TOutput can be defined by TSchema. We can use the same schema to validate TInput and incoming SQLite changes. diff --git a/docs/reference/powersync-db-collection/type-aliases/ConfigWithSQLiteTypes.md b/docs/reference/powersync-db-collection/type-aliases/ConfigWithSQLiteTypes.md index edc414511..df8a39bd3 100644 --- a/docs/reference/powersync-db-collection/type-aliases/ConfigWithSQLiteTypes.md +++ b/docs/reference/powersync-db-collection/type-aliases/ConfigWithSQLiteTypes.md @@ -9,6 +9,6 @@ title: ConfigWithSQLiteTypes type ConfigWithSQLiteTypes = object; ``` -Defined in: [definitions.ts:100](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L100) +Defined in: [definitions.ts:102](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L102) Config for when TInput and TOutput are both the SQLite types. diff --git a/docs/reference/powersync-db-collection/type-aliases/CustomSQLiteSerializer.md b/docs/reference/powersync-db-collection/type-aliases/CustomSQLiteSerializer.md index 898bf6119..ceebdd833 100644 --- a/docs/reference/powersync-db-collection/type-aliases/CustomSQLiteSerializer.md +++ b/docs/reference/powersync-db-collection/type-aliases/CustomSQLiteSerializer.md @@ -9,7 +9,7 @@ title: CustomSQLiteSerializer type CustomSQLiteSerializer = Partial<{ [Key in keyof TOutput]: (value: TOutput[Key]) => Key extends keyof TSQLite ? TSQLite[Key] : never }>; ``` -Defined in: [definitions.ts:52](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L52) +Defined in: [definitions.ts:54](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L54) A mapping type for custom serialization of object properties to SQLite-compatible values. diff --git a/docs/reference/powersync-db-collection/type-aliases/EagerSyncHooks.md b/docs/reference/powersync-db-collection/type-aliases/EagerSyncHooks.md new file mode 100644 index 000000000..72f264b34 --- /dev/null +++ b/docs/reference/powersync-db-collection/type-aliases/EagerSyncHooks.md @@ -0,0 +1,54 @@ +--- +id: EagerSyncHooks +title: EagerSyncHooks +--- + +# Type Alias: EagerSyncHooks + +```ts +type EagerSyncHooks = object; +``` + +Defined in: [definitions.ts:171](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L171) + +Eager sync mode hooks. +Called once when the collection sync starts and stops. + +## Properties + +### onLoad()? + +```ts +optional onLoad: () => CleanupFn | void | Promise; +``` + +Defined in: [definitions.ts:179](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L179) + +Called when the collection sync starts. +Use this to set up external data sources (e.g. subscribing to a sync stream). + +#### Returns + +`CleanupFn` \| `void` \| `Promise`\<`CleanupFn` \| `void`\> + +A cleanup function that is called when the collection sync is cleaned up. + +*** + +### onLoadSubset? + +```ts +optional onLoadSubset: never; +``` + +Defined in: [definitions.ts:180](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L180) + +*** + +### syncMode? + +```ts +optional syncMode: "eager"; +``` + +Defined in: [definitions.ts:172](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L172) diff --git a/docs/reference/powersync-db-collection/type-aliases/EnhancedPowerSyncCollectionConfig.md b/docs/reference/powersync-db-collection/type-aliases/EnhancedPowerSyncCollectionConfig.md index 711548258..4216af3e9 100644 --- a/docs/reference/powersync-db-collection/type-aliases/EnhancedPowerSyncCollectionConfig.md +++ b/docs/reference/powersync-db-collection/type-aliases/EnhancedPowerSyncCollectionConfig.md @@ -9,7 +9,7 @@ title: EnhancedPowerSyncCollectionConfig type EnhancedPowerSyncCollectionConfig = CollectionConfig> & object; ``` -Defined in: [definitions.ts:259](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L259) +Defined in: [definitions.ts:297](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L297) A CollectionConfig which includes utilities for PowerSync. diff --git a/docs/reference/powersync-db-collection/type-aliases/InferPowerSyncOutputType.md b/docs/reference/powersync-db-collection/type-aliases/InferPowerSyncOutputType.md index d7e31998e..2d8aa0f63 100644 --- a/docs/reference/powersync-db-collection/type-aliases/InferPowerSyncOutputType.md +++ b/docs/reference/powersync-db-collection/type-aliases/InferPowerSyncOutputType.md @@ -9,7 +9,7 @@ title: InferPowerSyncOutputType type InferPowerSyncOutputType = TSchema extends never ? ExtractedTable : InferSchemaOutput; ``` -Defined in: [definitions.ts:20](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L20) +Defined in: [definitions.ts:22](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L22) Small helper which determines the output type if: - Standard SQLite types are to be used OR diff --git a/docs/reference/powersync-db-collection/type-aliases/OnDemandSyncHooks.md b/docs/reference/powersync-db-collection/type-aliases/OnDemandSyncHooks.md new file mode 100644 index 000000000..5522dbeba --- /dev/null +++ b/docs/reference/powersync-db-collection/type-aliases/OnDemandSyncHooks.md @@ -0,0 +1,61 @@ +--- +id: OnDemandSyncHooks +title: OnDemandSyncHooks +--- + +# Type Alias: OnDemandSyncHooks + +```ts +type OnDemandSyncHooks = object; +``` + +Defined in: [definitions.ts:187](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L187) + +On-demand sync mode hooks. +Called each time a subset is loaded or unloaded in response to live query changes. + +## Properties + +### onLoad? + +```ts +optional onLoad: never; +``` + +Defined in: [definitions.ts:189](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L189) + +*** + +### onLoadSubset()? + +```ts +optional onLoadSubset: (options) => CleanupFn | void | Promise; +``` + +Defined in: [definitions.ts:198](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L198) + +Called when a subset of data is requested by a live query. +Use this to set up external data sources for the requested subset +(e.g. subscribing to a sync stream with parameters derived from the query predicate). + +#### Parameters + +##### options + +`LoadSubsetOptions` + +#### Returns + +`CleanupFn` \| `void` \| `Promise`\<`CleanupFn` \| `void`\> + +A cleanup function that is called when the subset is unloaded. + +*** + +### syncMode + +```ts +syncMode: "on-demand"; +``` + +Defined in: [definitions.ts:188](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L188) diff --git a/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionConfig.md b/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionConfig.md index d06b3d3b7..4b4a12d78 100644 --- a/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionConfig.md +++ b/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionConfig.md @@ -12,7 +12,7 @@ type PowerSyncCollectionConfig = BasePowerSyncCollectionConfig< | ConfigWithArbitraryCollectionTypes; ``` -Defined in: [definitions.ts:222](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L222) +Defined in: [definitions.ts:260](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L260) Configuration options for creating a PowerSync collection. diff --git a/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionMeta.md b/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionMeta.md index b7dddfa05..c6668b499 100644 --- a/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionMeta.md +++ b/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionMeta.md @@ -9,7 +9,7 @@ title: PowerSyncCollectionMeta type PowerSyncCollectionMeta = object; ``` -Defined in: [definitions.ts:235](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L235) +Defined in: [definitions.ts:273](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L273) Metadata for the PowerSync Collection. @@ -27,7 +27,7 @@ Metadata for the PowerSync Collection. metadataIsTracked: boolean; ``` -Defined in: [definitions.ts:253](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L253) +Defined in: [definitions.ts:291](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L291) Whether the PowerSync table tracks metadata. @@ -39,7 +39,7 @@ Whether the PowerSync table tracks metadata. serializeValue: (value) => ExtractedTable; ``` -Defined in: [definitions.ts:248](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L248) +Defined in: [definitions.ts:286](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L286) Serializes a collection value to the SQLite type @@ -61,7 +61,7 @@ Serializes a collection value to the SQLite type tableName: string; ``` -Defined in: [definitions.ts:239](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L239) +Defined in: [definitions.ts:277](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L277) The SQLite table representing the collection. @@ -73,6 +73,6 @@ The SQLite table representing the collection. trackedTableName: string; ``` -Defined in: [definitions.ts:243](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L243) +Defined in: [definitions.ts:281](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L281) The internal table used to track diffs for the collection. diff --git a/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionUtils.md b/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionUtils.md index 72a2803d6..6244bcff1 100644 --- a/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionUtils.md +++ b/docs/reference/powersync-db-collection/type-aliases/PowerSyncCollectionUtils.md @@ -9,7 +9,7 @@ title: PowerSyncCollectionUtils type PowerSyncCollectionUtils = object; ``` -Defined in: [definitions.ts:277](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L277) +Defined in: [definitions.ts:315](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L315) Collection-level utilities for PowerSync. @@ -27,7 +27,7 @@ Collection-level utilities for PowerSync. getMeta: () => PowerSyncCollectionMeta; ``` -Defined in: [definitions.ts:278](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L278) +Defined in: [definitions.ts:316](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L316) #### Returns diff --git a/docs/reference/powersync-db-collection/type-aliases/SerializerConfig.md b/docs/reference/powersync-db-collection/type-aliases/SerializerConfig.md index 2ce69107c..714a1b577 100644 --- a/docs/reference/powersync-db-collection/type-aliases/SerializerConfig.md +++ b/docs/reference/powersync-db-collection/type-aliases/SerializerConfig.md @@ -9,7 +9,7 @@ title: SerializerConfig type SerializerConfig = object; ``` -Defined in: [definitions.ts:61](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L61) +Defined in: [definitions.ts:63](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L63) ## Type Parameters @@ -29,7 +29,7 @@ Defined in: [definitions.ts:61](https://github.com/TanStack/db/blob/main/package onDeserializationError: (error) => void; ``` -Defined in: [definitions.ts:94](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L94) +Defined in: [definitions.ts:96](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L96) Application logic should ensure that incoming synced data is always valid. Failing to deserialize and apply incoming changes results in data inconsistency - which is a fatal error. @@ -53,7 +53,7 @@ Use this callback to react to deserialization errors. optional serializer: CustomSQLiteSerializer; ``` -Defined in: [definitions.ts:87](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L87) +Defined in: [definitions.ts:89](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L89) Optional partial serializer object for customizing how individual columns are serialized for SQLite. diff --git a/docs/reference/powersync-db-collection/variables/DEFAULT_BATCH_SIZE.md b/docs/reference/powersync-db-collection/variables/DEFAULT_BATCH_SIZE.md index f0a61f582..b4dfdb8a7 100644 --- a/docs/reference/powersync-db-collection/variables/DEFAULT_BATCH_SIZE.md +++ b/docs/reference/powersync-db-collection/variables/DEFAULT_BATCH_SIZE.md @@ -9,6 +9,6 @@ title: DEFAULT_BATCH_SIZE const DEFAULT_BATCH_SIZE: 1000 = 1000; ``` -Defined in: [definitions.ts:284](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L284) +Defined in: [definitions.ts:322](https://github.com/TanStack/db/blob/main/packages/powersync-db-collection/src/definitions.ts#L322) Default value for [PowerSyncCollectionConfig#syncBatchSize](../type-aliases/BasePowerSyncCollectionConfig.md). diff --git a/docs/reference/query-db-collection/functions/queryCollectionOptions.md b/docs/reference/query-db-collection/functions/queryCollectionOptions.md index 752d13b24..360652b59 100644 --- a/docs/reference/query-db-collection/functions/queryCollectionOptions.md +++ b/docs/reference/query-db-collection/functions/queryCollectionOptions.md @@ -11,7 +11,7 @@ title: queryCollectionOptions function queryCollectionOptions(config): CollectionConfig, TKey, T, QueryCollectionUtils, TKey, InferSchemaInput, TError>> & object; ``` -Defined in: [packages/query-db-collection/src/query.ts:400](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L400) +Defined in: [packages/query-db-collection/src/query.ts:431](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L431) Creates query collection options for use with a standard Collection. This integrates TanStack Query with TanStack DB for automatic synchronization. @@ -151,7 +151,7 @@ const todosCollection = createCollection( function queryCollectionOptions(config): CollectionConfig> & object; ``` -Defined in: [packages/query-db-collection/src/query.ts:435](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L435) +Defined in: [packages/query-db-collection/src/query.ts:466](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L466) Creates query collection options for use with a standard Collection. This integrates TanStack Query with TanStack DB for automatic synchronization. @@ -291,7 +291,7 @@ const todosCollection = createCollection( function queryCollectionOptions(config): CollectionConfig, TKey, T, QueryCollectionUtils, TKey, InferSchemaInput, TError>> & object; ``` -Defined in: [packages/query-db-collection/src/query.ts:468](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L468) +Defined in: [packages/query-db-collection/src/query.ts:499](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L499) Creates query collection options for use with a standard Collection. This integrates TanStack Query with TanStack DB for automatic synchronization. @@ -423,7 +423,7 @@ const todosCollection = createCollection( function queryCollectionOptions(config): CollectionConfig> & object; ``` -Defined in: [packages/query-db-collection/src/query.ts:502](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L502) +Defined in: [packages/query-db-collection/src/query.ts:533](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L533) Creates query collection options for use with a standard Collection. This integrates TanStack Query with TanStack DB for automatic synchronization. diff --git a/docs/reference/query-db-collection/interfaces/QueryCollectionConfig.md b/docs/reference/query-db-collection/interfaces/QueryCollectionConfig.md index c5e4fde05..a53cae230 100644 --- a/docs/reference/query-db-collection/interfaces/QueryCollectionConfig.md +++ b/docs/reference/query-db-collection/interfaces/QueryCollectionConfig.md @@ -5,7 +5,7 @@ title: QueryCollectionConfig # Interface: QueryCollectionConfig\ -Defined in: [packages/query-db-collection/src/query.ts:60](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L60) +Defined in: [packages/query-db-collection/src/query.ts:61](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L61) Configuration options for creating a Query Collection @@ -63,7 +63,7 @@ The schema type for validation optional enabled: Enabled; ``` -Defined in: [packages/query-db-collection/src/query.ts:86](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L86) +Defined in: [packages/query-db-collection/src/query.ts:87](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L87) Whether the query should automatically run (default: true) @@ -75,7 +75,7 @@ Whether the query should automatically run (default: true) optional meta: Record; ``` -Defined in: [packages/query-db-collection/src/query.ts:142](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L142) +Defined in: [packages/query-db-collection/src/query.ts:144](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L144) Metadata to pass to the query. Available in queryFn via context.meta @@ -101,13 +101,23 @@ meta: { *** +### persistedGcTime? + +```ts +optional persistedGcTime: number; +``` + +Defined in: [packages/query-db-collection/src/query.ts:122](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L122) + +*** + ### queryClient ```ts queryClient: QueryClient; ``` -Defined in: [packages/query-db-collection/src/query.ts:82](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L82) +Defined in: [packages/query-db-collection/src/query.ts:83](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L83) The TanStack Query client instance @@ -119,7 +129,7 @@ The TanStack Query client instance queryFn: TQueryFn extends (context) => any[] | Promise ? (context) => T[] | Promise : TQueryFn; ``` -Defined in: [packages/query-db-collection/src/query.ts:74](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L74) +Defined in: [packages/query-db-collection/src/query.ts:75](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L75) Function that fetches data from the server. Must return the complete collection state @@ -131,7 +141,7 @@ Function that fetches data from the server. Must return the complete collection queryKey: TQueryKey | TQueryKeyBuilder; ``` -Defined in: [packages/query-db-collection/src/query.ts:72](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L72) +Defined in: [packages/query-db-collection/src/query.ts:73](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L73) The query key used by TanStack Query to identify this query @@ -143,7 +153,7 @@ The query key used by TanStack Query to identify this query optional refetchInterval: number | false | (query) => number | false | undefined; ``` -Defined in: [packages/query-db-collection/src/query.ts:93](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L93) +Defined in: [packages/query-db-collection/src/query.ts:94](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L94) *** @@ -153,7 +163,7 @@ Defined in: [packages/query-db-collection/src/query.ts:93](https://github.com/Ta optional retry: RetryValue; ``` -Defined in: [packages/query-db-collection/src/query.ts:100](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L100) +Defined in: [packages/query-db-collection/src/query.ts:101](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L101) *** @@ -163,7 +173,7 @@ Defined in: [packages/query-db-collection/src/query.ts:100](https://github.com/T optional retryDelay: RetryDelayValue; ``` -Defined in: [packages/query-db-collection/src/query.ts:107](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L107) +Defined in: [packages/query-db-collection/src/query.ts:108](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L108) *** @@ -173,7 +183,7 @@ Defined in: [packages/query-db-collection/src/query.ts:107](https://github.com/T optional select: (data) => T[]; ``` -Defined in: [packages/query-db-collection/src/query.ts:80](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L80) +Defined in: [packages/query-db-collection/src/query.ts:81](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L81) #### Parameters @@ -193,4 +203,4 @@ Defined in: [packages/query-db-collection/src/query.ts:80](https://github.com/Ta optional staleTime: StaleTimeFunction; ``` -Defined in: [packages/query-db-collection/src/query.ts:114](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L114) +Defined in: [packages/query-db-collection/src/query.ts:115](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L115) diff --git a/docs/reference/query-db-collection/interfaces/QueryCollectionUtils.md b/docs/reference/query-db-collection/interfaces/QueryCollectionUtils.md index f88d398a4..d30be795f 100644 --- a/docs/reference/query-db-collection/interfaces/QueryCollectionUtils.md +++ b/docs/reference/query-db-collection/interfaces/QueryCollectionUtils.md @@ -5,7 +5,7 @@ title: QueryCollectionUtils # Interface: QueryCollectionUtils\ -Defined in: [packages/query-db-collection/src/query.ts:161](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L161) +Defined in: [packages/query-db-collection/src/query.ts:163](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L163) Utility methods available on Query Collections for direct writes and manual operations. Direct writes bypass the normal query/mutation flow and write directly to the synced data store. @@ -54,7 +54,7 @@ The type of errors that can occur during queries clearError: () => Promise; ``` -Defined in: [packages/query-db-collection/src/query.ts:206](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L206) +Defined in: [packages/query-db-collection/src/query.ts:208](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L208) Clear the error state and trigger a refetch of the query @@ -76,7 +76,7 @@ Error if the refetch fails dataUpdatedAt: number; ``` -Defined in: [packages/query-db-collection/src/query.ts:197](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L197) +Defined in: [packages/query-db-collection/src/query.ts:199](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L199) Get timestamp of last successful data update (in milliseconds) @@ -88,7 +88,7 @@ Get timestamp of last successful data update (in milliseconds) errorCount: number; ``` -Defined in: [packages/query-db-collection/src/query.ts:189](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L189) +Defined in: [packages/query-db-collection/src/query.ts:191](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L191) Get the number of consecutive sync failures. Incremented only when query fails completely (not per retry attempt); reset on success. @@ -101,7 +101,7 @@ Incremented only when query fails completely (not per retry attempt); reset on s fetchStatus: "idle" | "fetching" | "paused"; ``` -Defined in: [packages/query-db-collection/src/query.ts:199](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L199) +Defined in: [packages/query-db-collection/src/query.ts:201](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L201) Get current fetch status @@ -113,7 +113,7 @@ Get current fetch status isError: boolean; ``` -Defined in: [packages/query-db-collection/src/query.ts:184](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L184) +Defined in: [packages/query-db-collection/src/query.ts:186](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L186) Check if the collection is in an error state @@ -125,7 +125,7 @@ Check if the collection is in an error state isFetching: boolean; ``` -Defined in: [packages/query-db-collection/src/query.ts:191](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L191) +Defined in: [packages/query-db-collection/src/query.ts:193](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L193) Check if query is currently fetching (initial or background) @@ -137,7 +137,7 @@ Check if query is currently fetching (initial or background) isLoading: boolean; ``` -Defined in: [packages/query-db-collection/src/query.ts:195](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L195) +Defined in: [packages/query-db-collection/src/query.ts:197](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L197) Check if query is loading for the first time (no data yet) @@ -149,7 +149,7 @@ Check if query is loading for the first time (no data yet) isRefetching: boolean; ``` -Defined in: [packages/query-db-collection/src/query.ts:193](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L193) +Defined in: [packages/query-db-collection/src/query.ts:195](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L195) Check if query is refetching in background (not initial fetch) @@ -161,7 +161,7 @@ Check if query is refetching in background (not initial fetch) lastError: TError | undefined; ``` -Defined in: [packages/query-db-collection/src/query.ts:182](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L182) +Defined in: [packages/query-db-collection/src/query.ts:184](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L184) Get the last error encountered by the query (if any); reset on success @@ -173,7 +173,7 @@ Get the last error encountered by the query (if any); reset on success refetch: RefetchFn; ``` -Defined in: [packages/query-db-collection/src/query.ts:168](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L168) +Defined in: [packages/query-db-collection/src/query.ts:170](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L170) Manually trigger a refetch of the query @@ -185,7 +185,7 @@ Manually trigger a refetch of the query writeBatch: (callback) => void; ``` -Defined in: [packages/query-db-collection/src/query.ts:178](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L178) +Defined in: [packages/query-db-collection/src/query.ts:180](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L180) Execute multiple write operations as a single atomic batch to the synced data store @@ -207,7 +207,7 @@ Execute multiple write operations as a single atomic batch to the synced data st writeDelete: (keys) => void; ``` -Defined in: [packages/query-db-collection/src/query.ts:174](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L174) +Defined in: [packages/query-db-collection/src/query.ts:176](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L176) Delete one or more items directly from the synced data store without triggering a query refetch or optimistic update @@ -229,7 +229,7 @@ Delete one or more items directly from the synced data store without triggering writeInsert: (data) => void; ``` -Defined in: [packages/query-db-collection/src/query.ts:170](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L170) +Defined in: [packages/query-db-collection/src/query.ts:172](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L172) Insert one or more items directly into the synced data store without triggering a query refetch or optimistic update @@ -251,7 +251,7 @@ Insert one or more items directly into the synced data store without triggering writeUpdate: (updates) => void; ``` -Defined in: [packages/query-db-collection/src/query.ts:172](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L172) +Defined in: [packages/query-db-collection/src/query.ts:174](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L174) Update one or more items directly in the synced data store without triggering a query refetch or optimistic update @@ -273,7 +273,7 @@ Update one or more items directly in the synced data store without triggering a writeUpsert: (data) => void; ``` -Defined in: [packages/query-db-collection/src/query.ts:176](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L176) +Defined in: [packages/query-db-collection/src/query.ts:178](https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L178) Insert or update one or more items directly in the synced data store without triggering a query refetch or optimistic update diff --git a/docs/reference/trailbase-db-collection/classes/ExpectedDeleteTypeError.md b/docs/reference/trailbase-db-collection/classes/ExpectedDeleteTypeError.md new file mode 100644 index 000000000..e27cf4846 --- /dev/null +++ b/docs/reference/trailbase-db-collection/classes/ExpectedDeleteTypeError.md @@ -0,0 +1,220 @@ +--- +id: ExpectedDeleteTypeError +title: ExpectedDeleteTypeError +--- + +# Class: ExpectedDeleteTypeError + +Defined in: [packages/trailbase-db-collection/src/errors.ts:32](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/errors.ts#L32) + +## Extends + +- [`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md) + +## Constructors + +### Constructor + +```ts +new ExpectedDeleteTypeError(actualType): ExpectedDeleteTypeError; +``` + +Defined in: [packages/trailbase-db-collection/src/errors.ts:33](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/errors.ts#L33) + +#### Parameters + +##### actualType + +`string` + +#### Returns + +`ExpectedDeleteTypeError` + +#### Overrides + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`constructor`](TrailBaseDBCollectionError.md#constructor) + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`cause`](TrailBaseDBCollectionError.md#cause) + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`message`](TrailBaseDBCollectionError.md#message) + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`name`](TrailBaseDBCollectionError.md#name) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`stack`](TrailBaseDBCollectionError.md#stack) + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:67 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`stackTraceLimit`](TrailBaseDBCollectionError.md#stacktracelimit) + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:51 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`captureStackTrace`](TrailBaseDBCollectionError.md#capturestacktrace) + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:55 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`prepareStackTrace`](TrailBaseDBCollectionError.md#preparestacktrace) diff --git a/docs/reference/trailbase-db-collection/classes/ExpectedInsertTypeError.md b/docs/reference/trailbase-db-collection/classes/ExpectedInsertTypeError.md new file mode 100644 index 000000000..16698b8ce --- /dev/null +++ b/docs/reference/trailbase-db-collection/classes/ExpectedInsertTypeError.md @@ -0,0 +1,220 @@ +--- +id: ExpectedInsertTypeError +title: ExpectedInsertTypeError +--- + +# Class: ExpectedInsertTypeError + +Defined in: [packages/trailbase-db-collection/src/errors.ts:18](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/errors.ts#L18) + +## Extends + +- [`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md) + +## Constructors + +### Constructor + +```ts +new ExpectedInsertTypeError(actualType): ExpectedInsertTypeError; +``` + +Defined in: [packages/trailbase-db-collection/src/errors.ts:19](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/errors.ts#L19) + +#### Parameters + +##### actualType + +`string` + +#### Returns + +`ExpectedInsertTypeError` + +#### Overrides + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`constructor`](TrailBaseDBCollectionError.md#constructor) + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`cause`](TrailBaseDBCollectionError.md#cause) + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`message`](TrailBaseDBCollectionError.md#message) + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`name`](TrailBaseDBCollectionError.md#name) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`stack`](TrailBaseDBCollectionError.md#stack) + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:67 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`stackTraceLimit`](TrailBaseDBCollectionError.md#stacktracelimit) + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:51 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`captureStackTrace`](TrailBaseDBCollectionError.md#capturestacktrace) + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:55 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`prepareStackTrace`](TrailBaseDBCollectionError.md#preparestacktrace) diff --git a/docs/reference/trailbase-db-collection/classes/ExpectedUpdateTypeError.md b/docs/reference/trailbase-db-collection/classes/ExpectedUpdateTypeError.md new file mode 100644 index 000000000..993debc67 --- /dev/null +++ b/docs/reference/trailbase-db-collection/classes/ExpectedUpdateTypeError.md @@ -0,0 +1,220 @@ +--- +id: ExpectedUpdateTypeError +title: ExpectedUpdateTypeError +--- + +# Class: ExpectedUpdateTypeError + +Defined in: [packages/trailbase-db-collection/src/errors.ts:25](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/errors.ts#L25) + +## Extends + +- [`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md) + +## Constructors + +### Constructor + +```ts +new ExpectedUpdateTypeError(actualType): ExpectedUpdateTypeError; +``` + +Defined in: [packages/trailbase-db-collection/src/errors.ts:26](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/errors.ts#L26) + +#### Parameters + +##### actualType + +`string` + +#### Returns + +`ExpectedUpdateTypeError` + +#### Overrides + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`constructor`](TrailBaseDBCollectionError.md#constructor) + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`cause`](TrailBaseDBCollectionError.md#cause) + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`message`](TrailBaseDBCollectionError.md#message) + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`name`](TrailBaseDBCollectionError.md#name) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`stack`](TrailBaseDBCollectionError.md#stack) + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:67 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`stackTraceLimit`](TrailBaseDBCollectionError.md#stacktracelimit) + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:51 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`captureStackTrace`](TrailBaseDBCollectionError.md#capturestacktrace) + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:55 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`prepareStackTrace`](TrailBaseDBCollectionError.md#preparestacktrace) diff --git a/docs/reference/trailbase-db-collection/classes/TimeoutWaitingForIdsError.md b/docs/reference/trailbase-db-collection/classes/TimeoutWaitingForIdsError.md new file mode 100644 index 000000000..3b2d162a8 --- /dev/null +++ b/docs/reference/trailbase-db-collection/classes/TimeoutWaitingForIdsError.md @@ -0,0 +1,220 @@ +--- +id: TimeoutWaitingForIdsError +title: TimeoutWaitingForIdsError +--- + +# Class: TimeoutWaitingForIdsError + +Defined in: [packages/trailbase-db-collection/src/errors.ts:11](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/errors.ts#L11) + +## Extends + +- [`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md) + +## Constructors + +### Constructor + +```ts +new TimeoutWaitingForIdsError(ids): TimeoutWaitingForIdsError; +``` + +Defined in: [packages/trailbase-db-collection/src/errors.ts:12](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/errors.ts#L12) + +#### Parameters + +##### ids + +`string` + +#### Returns + +`TimeoutWaitingForIdsError` + +#### Overrides + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`constructor`](TrailBaseDBCollectionError.md#constructor) + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`cause`](TrailBaseDBCollectionError.md#cause) + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`message`](TrailBaseDBCollectionError.md#message) + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`name`](TrailBaseDBCollectionError.md#name) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`stack`](TrailBaseDBCollectionError.md#stack) + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:67 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`stackTraceLimit`](TrailBaseDBCollectionError.md#stacktracelimit) + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:51 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`captureStackTrace`](TrailBaseDBCollectionError.md#capturestacktrace) + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:55 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +[`TrailBaseDBCollectionError`](TrailBaseDBCollectionError.md).[`prepareStackTrace`](TrailBaseDBCollectionError.md#preparestacktrace) diff --git a/docs/reference/trailbase-db-collection/classes/TrailBaseDBCollectionError.md b/docs/reference/trailbase-db-collection/classes/TrailBaseDBCollectionError.md new file mode 100644 index 000000000..83731641a --- /dev/null +++ b/docs/reference/trailbase-db-collection/classes/TrailBaseDBCollectionError.md @@ -0,0 +1,243 @@ +--- +id: TrailBaseDBCollectionError +title: TrailBaseDBCollectionError +--- + +# Class: TrailBaseDBCollectionError + +Defined in: [packages/trailbase-db-collection/src/errors.ts:4](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/errors.ts#L4) + +## Extends + +- `TanStackDBError` + +## Extended by + +- [`TimeoutWaitingForIdsError`](TimeoutWaitingForIdsError.md) +- [`ExpectedInsertTypeError`](ExpectedInsertTypeError.md) +- [`ExpectedUpdateTypeError`](ExpectedUpdateTypeError.md) +- [`ExpectedDeleteTypeError`](ExpectedDeleteTypeError.md) + +## Constructors + +### Constructor + +```ts +new TrailBaseDBCollectionError(message): TrailBaseDBCollectionError; +``` + +Defined in: [packages/trailbase-db-collection/src/errors.ts:5](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/errors.ts#L5) + +#### Parameters + +##### message + +`string` + +#### Returns + +`TrailBaseDBCollectionError` + +#### Overrides + +```ts +TanStackDBError.constructor +``` + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26 + +#### Inherited from + +```ts +TanStackDBError.cause +``` + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077 + +#### Inherited from + +```ts +TanStackDBError.message +``` + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +```ts +TanStackDBError.name +``` + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078 + +#### Inherited from + +```ts +TanStackDBError.stack +``` + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:67 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +```ts +TanStackDBError.stackTraceLimit +``` + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:51 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +```ts +TanStackDBError.captureStackTrace +``` + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@25.2.2/node\_modules/@types/node/globals.d.ts:55 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +```ts +TanStackDBError.prepareStackTrace +``` diff --git a/docs/reference/trailbase-db-collection/functions/trailBaseCollectionOptions.md b/docs/reference/trailbase-db-collection/functions/trailBaseCollectionOptions.md new file mode 100644 index 000000000..5905d86c6 --- /dev/null +++ b/docs/reference/trailbase-db-collection/functions/trailBaseCollectionOptions.md @@ -0,0 +1,36 @@ +--- +id: trailBaseCollectionOptions +title: trailBaseCollectionOptions +--- + +# Function: trailBaseCollectionOptions() + +```ts +function trailBaseCollectionOptions(config): CollectionConfig & object; +``` + +Defined in: [packages/trailbase-db-collection/src/trailbase.ts:121](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/trailbase.ts#L121) + +## Type Parameters + +### TItem + +`TItem` *extends* `ShapeOf`\<`TRecord`\> + +### TRecord + +`TRecord` *extends* `ShapeOf`\<`TItem`\> = `TItem` + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + +## Parameters + +### config + +[`TrailBaseCollectionConfig`](../interfaces/TrailBaseCollectionConfig.md)\<`TItem`, `TRecord`, `TKey`\> + +## Returns + +`CollectionConfig`\<`TItem`, `TKey`, `never`, [`TrailBaseCollectionUtils`](../interfaces/TrailBaseCollectionUtils.md)\> & `object` diff --git a/docs/reference/trailbase-db-collection/index.md b/docs/reference/trailbase-db-collection/index.md new file mode 100644 index 000000000..b751f697e --- /dev/null +++ b/docs/reference/trailbase-db-collection/index.md @@ -0,0 +1,23 @@ +--- +id: "@tanstack/trailbase-db-collection" +title: "@tanstack/trailbase-db-collection" +--- + +# @tanstack/trailbase-db-collection + +## Classes + +- [ExpectedDeleteTypeError](classes/ExpectedDeleteTypeError.md) +- [ExpectedInsertTypeError](classes/ExpectedInsertTypeError.md) +- [ExpectedUpdateTypeError](classes/ExpectedUpdateTypeError.md) +- [TimeoutWaitingForIdsError](classes/TimeoutWaitingForIdsError.md) +- [TrailBaseDBCollectionError](classes/TrailBaseDBCollectionError.md) + +## Interfaces + +- [TrailBaseCollectionConfig](interfaces/TrailBaseCollectionConfig.md) +- [TrailBaseCollectionUtils](interfaces/TrailBaseCollectionUtils.md) + +## Functions + +- [trailBaseCollectionOptions](functions/trailBaseCollectionOptions.md) diff --git a/docs/reference/trailbase-db-collection/interfaces/TrailBaseCollectionConfig.md b/docs/reference/trailbase-db-collection/interfaces/TrailBaseCollectionConfig.md new file mode 100644 index 000000000..40b63eb70 --- /dev/null +++ b/docs/reference/trailbase-db-collection/interfaces/TrailBaseCollectionConfig.md @@ -0,0 +1,76 @@ +--- +id: TrailBaseCollectionConfig +title: TrailBaseCollectionConfig +--- + +# Interface: TrailBaseCollectionConfig\ + +Defined in: [packages/trailbase-db-collection/src/trailbase.ts:92](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/trailbase.ts#L92) + +Configuration interface for Trailbase Collection + +## Extends + +- `Omit`\<`BaseCollectionConfig`\<`TItem`, `TKey`\>, `"onInsert"` \| `"onUpdate"` \| `"onDelete"` \| `"syncMode"`\> + +## Type Parameters + +### TItem + +`TItem` *extends* `ShapeOf`\<`TRecord`\> + +### TRecord + +`TRecord` *extends* `ShapeOf`\<`TItem`\> = `TItem` + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + +## Properties + +### parse + +```ts +parse: Conversions; +``` + +Defined in: [packages/trailbase-db-collection/src/trailbase.ts:111](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/trailbase.ts#L111) + +*** + +### recordApi + +```ts +recordApi: RecordApi; +``` + +Defined in: [packages/trailbase-db-collection/src/trailbase.ts:103](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/trailbase.ts#L103) + +Record API name + +*** + +### serialize + +```ts +serialize: Conversions; +``` + +Defined in: [packages/trailbase-db-collection/src/trailbase.ts:112](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/trailbase.ts#L112) + +*** + +### syncMode? + +```ts +optional syncMode: SyncMode; +``` + +Defined in: [packages/trailbase-db-collection/src/trailbase.ts:109](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/trailbase.ts#L109) + +The mode of sync to use for the collection. + +#### Default + +`eager` diff --git a/docs/reference/trailbase-db-collection/interfaces/TrailBaseCollectionUtils.md b/docs/reference/trailbase-db-collection/interfaces/TrailBaseCollectionUtils.md new file mode 100644 index 000000000..ef951da0d --- /dev/null +++ b/docs/reference/trailbase-db-collection/interfaces/TrailBaseCollectionUtils.md @@ -0,0 +1,32 @@ +--- +id: TrailBaseCollectionUtils +title: TrailBaseCollectionUtils +--- + +# Interface: TrailBaseCollectionUtils + +Defined in: [packages/trailbase-db-collection/src/trailbase.ts:117](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/trailbase.ts#L117) + +## Extends + +- `UtilsRecord` + +## Indexable + +```ts +[key: string]: any +``` + +## Properties + +### cancel() + +```ts +cancel: () => void; +``` + +Defined in: [packages/trailbase-db-collection/src/trailbase.ts:118](https://github.com/TanStack/db/blob/main/packages/trailbase-db-collection/src/trailbase.ts#L118) + +#### Returns + +`void` diff --git a/docs/reference/type-aliases/ApplyJoinOptionalityToMergedSchema.md b/docs/reference/type-aliases/ApplyJoinOptionalityToMergedSchema.md index 7861710af..de18e0b6d 100644 --- a/docs/reference/type-aliases/ApplyJoinOptionalityToMergedSchema.md +++ b/docs/reference/type-aliases/ApplyJoinOptionalityToMergedSchema.md @@ -9,7 +9,7 @@ title: ApplyJoinOptionalityToMergedSchema type ApplyJoinOptionalityToMergedSchema = { [K in keyof TExistingSchema]: K extends TFromSourceName ? TJoinType extends "right" | "full" ? TExistingSchema[K] | undefined : TExistingSchema[K] : TExistingSchema[K] } & { [K in keyof TNewSchema]: TJoinType extends "left" | "full" ? TNewSchema[K] | undefined : TNewSchema[K] }; ``` -Defined in: [packages/db/src/query/builder/types.ts:636](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L636) +Defined in: [packages/db/src/query/builder/types.ts:779](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L779) ApplyJoinOptionalityToMergedSchema - Applies optionality rules when merging schemas diff --git a/docs/reference/type-aliases/ChangeListener.md b/docs/reference/type-aliases/ChangeListener.md index 923a25ca4..0d82c8cdb 100644 --- a/docs/reference/type-aliases/ChangeListener.md +++ b/docs/reference/type-aliases/ChangeListener.md @@ -9,7 +9,7 @@ title: ChangeListener type ChangeListener = (changes) => void; ``` -Defined in: [packages/db/src/types.ts:879](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L879) +Defined in: [packages/db/src/types.ts:919](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L919) Function type for listening to collection changes @@ -27,7 +27,7 @@ Function type for listening to collection changes ### changes -[`ChangeMessage`](../interfaces/ChangeMessage.md)\<`T`, `TKey`\>[] +[`ChangeMessage`](../interfaces/ChangeMessage.md)\<[`WithVirtualProps`](WithVirtualProps.md)\<`T`, `TKey`\>, `TKey`\>[] Array of change messages describing what happened diff --git a/docs/reference/type-aliases/ChangeMessageOrDeleteKeyMessage.md b/docs/reference/type-aliases/ChangeMessageOrDeleteKeyMessage.md index 6ab1778d0..59b97fa11 100644 --- a/docs/reference/type-aliases/ChangeMessageOrDeleteKeyMessage.md +++ b/docs/reference/type-aliases/ChangeMessageOrDeleteKeyMessage.md @@ -11,7 +11,7 @@ type ChangeMessageOrDeleteKeyMessage = | DeleteKeyMessage; ``` -Defined in: [packages/db/src/types.ts:375](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L375) +Defined in: [packages/db/src/types.ts:397](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L397) ## Type Parameters diff --git a/docs/reference/type-aliases/ChangesPayload.md b/docs/reference/type-aliases/ChangesPayload.md index 83d5f300d..387c8fb90 100644 --- a/docs/reference/type-aliases/ChangesPayload.md +++ b/docs/reference/type-aliases/ChangesPayload.md @@ -3,16 +3,20 @@ id: ChangesPayload title: ChangesPayload --- -# Type Alias: ChangesPayload\ +# Type Alias: ChangesPayload\ ```ts -type ChangesPayload = ChangeMessage[]; +type ChangesPayload = ChangeMessage, TKey>[]; ``` -Defined in: [packages/db/src/types.ts:742](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L742) +Defined in: [packages/db/src/types.ts:779](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L779) ## Type Parameters ### T `T` *extends* `object` = `Record`\<`string`, `unknown`\> + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` diff --git a/docs/reference/type-aliases/CleanupFn.md b/docs/reference/type-aliases/CleanupFn.md index a5e5cd695..83dc420aa 100644 --- a/docs/reference/type-aliases/CleanupFn.md +++ b/docs/reference/type-aliases/CleanupFn.md @@ -9,7 +9,7 @@ title: CleanupFn type CleanupFn = () => void; ``` -Defined in: [packages/db/src/types.ts:318](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L318) +Defined in: [packages/db/src/types.ts:320](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L320) ## Returns diff --git a/docs/reference/type-aliases/CollectionConfigSingleRowOption.md b/docs/reference/type-aliases/CollectionConfigSingleRowOption.md index 3c9283c9c..b376bac57 100644 --- a/docs/reference/type-aliases/CollectionConfigSingleRowOption.md +++ b/docs/reference/type-aliases/CollectionConfigSingleRowOption.md @@ -9,7 +9,7 @@ title: CollectionConfigSingleRowOption type CollectionConfigSingleRowOption = CollectionConfig & MaybeSingleResult; ``` -Defined in: [packages/db/src/types.ts:735](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L735) +Defined in: [packages/db/src/types.ts:772](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L772) ## Type Parameters diff --git a/docs/reference/type-aliases/CollectionStatus.md b/docs/reference/type-aliases/CollectionStatus.md index b5543c2e7..913818194 100644 --- a/docs/reference/type-aliases/CollectionStatus.md +++ b/docs/reference/type-aliases/CollectionStatus.md @@ -9,7 +9,7 @@ title: CollectionStatus type CollectionStatus = "idle" | "loading" | "ready" | "error" | "cleaned-up"; ``` -Defined in: [packages/db/src/types.ts:485](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L485) +Defined in: [packages/db/src/types.ts:507](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L507) Collection status values for lifecycle management diff --git a/docs/reference/type-aliases/ContextSchema.md b/docs/reference/type-aliases/ContextSchema.md index ef1f4f00c..09d96d6a3 100644 --- a/docs/reference/type-aliases/ContextSchema.md +++ b/docs/reference/type-aliases/ContextSchema.md @@ -9,7 +9,7 @@ title: ContextSchema type ContextSchema = Record; ``` -Defined in: [packages/db/src/query/builder/types.ts:64](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L64) +Defined in: [packages/db/src/query/builder/types.ts:68](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L68) ContextSchema - The shape of available tables/collections in a query context diff --git a/docs/reference/type-aliases/CursorExpressions.md b/docs/reference/type-aliases/CursorExpressions.md index 9dc585805..2f84898f3 100644 --- a/docs/reference/type-aliases/CursorExpressions.md +++ b/docs/reference/type-aliases/CursorExpressions.md @@ -9,7 +9,7 @@ title: CursorExpressions type CursorExpressions = object; ``` -Defined in: [packages/db/src/types.ts:264](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L264) +Defined in: [packages/db/src/types.ts:266](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L266) Cursor expressions for pagination, passed separately from the main `where` clause. The sync layer can choose to use cursor-based pagination (combining these with the where) @@ -25,7 +25,7 @@ Neither expression includes the main `where` clause - they are cursor-specific o optional lastKey: string | number; ``` -Defined in: [packages/db/src/types.ts:282](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L282) +Defined in: [packages/db/src/types.ts:284](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L284) The key of the last item that was loaded. Can be used by sync layers for tracking or deduplication. @@ -38,7 +38,7 @@ Can be used by sync layers for tracking or deduplication. whereCurrent: BasicExpression; ``` -Defined in: [packages/db/src/types.ts:277](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L277) +Defined in: [packages/db/src/types.ts:279](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L279) Expression for rows equal to the current cursor value (first orderBy column only). Used to handle tie-breaking/duplicates at the boundary. @@ -52,7 +52,7 @@ Example: eq(col1, v1) or for Dates: and(gte(col1, v1), lt(col1, v1+1ms)) whereFrom: BasicExpression; ``` -Defined in: [packages/db/src/types.ts:271](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L271) +Defined in: [packages/db/src/types.ts:273](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L273) Expression for rows greater than (after) the cursor value. For multi-column orderBy, this is a composite cursor using OR of conditions. diff --git a/docs/reference/type-aliases/DeleteKeyMessage.md b/docs/reference/type-aliases/DeleteKeyMessage.md index bf2c1a4e1..c28ab6b53 100644 --- a/docs/reference/type-aliases/DeleteKeyMessage.md +++ b/docs/reference/type-aliases/DeleteKeyMessage.md @@ -9,7 +9,7 @@ title: DeleteKeyMessage type DeleteKeyMessage = Omit, "value" | "previousValue" | "type"> & object; ``` -Defined in: [packages/db/src/types.ts:370](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L370) +Defined in: [packages/db/src/types.ts:392](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L392) ## Type Declaration diff --git a/docs/reference/type-aliases/DeleteMutationFn.md b/docs/reference/type-aliases/DeleteMutationFn.md index f4458323f..ff5b3bd6f 100644 --- a/docs/reference/type-aliases/DeleteMutationFn.md +++ b/docs/reference/type-aliases/DeleteMutationFn.md @@ -9,7 +9,7 @@ title: DeleteMutationFn type DeleteMutationFn = (params) => Promise; ``` -Defined in: [packages/db/src/types.ts:463](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L463) +Defined in: [packages/db/src/types.ts:485](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L485) ## Type Parameters diff --git a/docs/reference/type-aliases/DeleteMutationFnParams.md b/docs/reference/type-aliases/DeleteMutationFnParams.md index f3821d576..a0480fd0e 100644 --- a/docs/reference/type-aliases/DeleteMutationFnParams.md +++ b/docs/reference/type-aliases/DeleteMutationFnParams.md @@ -9,7 +9,7 @@ title: DeleteMutationFnParams type DeleteMutationFnParams = object; ``` -Defined in: [packages/db/src/types.ts:440](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L440) +Defined in: [packages/db/src/types.ts:462](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L462) ## Type Parameters @@ -33,7 +33,7 @@ Defined in: [packages/db/src/types.ts:440](https://github.com/TanStack/db/blob/m collection: Collection; ``` -Defined in: [packages/db/src/types.ts:446](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L446) +Defined in: [packages/db/src/types.ts:468](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L468) *** @@ -43,4 +43,4 @@ Defined in: [packages/db/src/types.ts:446](https://github.com/TanStack/db/blob/m transaction: TransactionWithMutations; ``` -Defined in: [packages/db/src/types.ts:445](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L445) +Defined in: [packages/db/src/types.ts:467](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L467) diff --git a/docs/reference/type-aliases/DeltaEvent.md b/docs/reference/type-aliases/DeltaEvent.md new file mode 100644 index 000000000..9fd3b8909 --- /dev/null +++ b/docs/reference/type-aliases/DeltaEvent.md @@ -0,0 +1,159 @@ +--- +id: DeltaEvent +title: DeltaEvent +--- + +# Type Alias: DeltaEvent\ + +```ts +type DeltaEvent = + | { + key: TKey; + metadata?: Record; + type: "enter"; + value: TRow; +} + | { + key: TKey; + metadata?: Record; + type: "exit"; + value: TRow; +} + | { + key: TKey; + metadata?: Record; + previousValue: TRow; + type: "update"; + value: TRow; +}; +``` + +Defined in: [packages/db/src/query/effect.ts:38](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L38) + +Delta event emitted when a row enters, exits, or updates within a query result + +## Type Parameters + +### TRow + +`TRow` *extends* `object` = `Record`\<`string`, `unknown`\> + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + +## Type Declaration + +```ts +{ + key: TKey; + metadata?: Record; + type: "enter"; + value: TRow; +} +``` + +### key + +```ts +key: TKey; +``` + +### metadata? + +```ts +optional metadata: Record; +``` + +### type + +```ts +type: "enter"; +``` + +### value + +```ts +value: TRow; +``` + +Current value for the entering row + +```ts +{ + key: TKey; + metadata?: Record; + type: "exit"; + value: TRow; +} +``` + +### key + +```ts +key: TKey; +``` + +### metadata? + +```ts +optional metadata: Record; +``` + +### type + +```ts +type: "exit"; +``` + +### value + +```ts +value: TRow; +``` + +Current value for the exiting row + +```ts +{ + key: TKey; + metadata?: Record; + previousValue: TRow; + type: "update"; + value: TRow; +} +``` + +### key + +```ts +key: TKey; +``` + +### metadata? + +```ts +optional metadata: Record; +``` + +### previousValue + +```ts +previousValue: TRow; +``` + +Previous value before the batch + +### type + +```ts +type: "update"; +``` + +### value + +```ts +value: TRow; +``` + +Current value after the update diff --git a/docs/reference/type-aliases/DeltaType.md b/docs/reference/type-aliases/DeltaType.md new file mode 100644 index 000000000..7d0aeedff --- /dev/null +++ b/docs/reference/type-aliases/DeltaType.md @@ -0,0 +1,14 @@ +--- +id: DeltaType +title: DeltaType +--- + +# Type Alias: DeltaType + +```ts +type DeltaType = "enter" | "exit" | "update"; +``` + +Defined in: [packages/db/src/query/effect.ts:35](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L35) + +Event types for query result deltas diff --git a/docs/reference/type-aliases/EffectQueryInput.md b/docs/reference/type-aliases/EffectQueryInput.md new file mode 100644 index 000000000..6b171ac5f --- /dev/null +++ b/docs/reference/type-aliases/EffectQueryInput.md @@ -0,0 +1,22 @@ +--- +id: EffectQueryInput +title: EffectQueryInput +--- + +# Type Alias: EffectQueryInput\ + +```ts +type EffectQueryInput = + | (q) => QueryBuilder +| QueryBuilder; +``` + +Defined in: [packages/db/src/query/effect.ts:75](https://github.com/TanStack/db/blob/main/packages/db/src/query/effect.ts#L75) + +Query input - can be a builder function or a prebuilt query + +## Type Parameters + +### TContext + +`TContext` *extends* [`Context`](../interfaces/Context.md) diff --git a/docs/reference/type-aliases/ExtractContext.md b/docs/reference/type-aliases/ExtractContext.md index 62f6183d8..4bbdc5502 100644 --- a/docs/reference/type-aliases/ExtractContext.md +++ b/docs/reference/type-aliases/ExtractContext.md @@ -9,7 +9,7 @@ title: ExtractContext type ExtractContext = T extends BaseQueryBuilder ? TContext : T extends QueryBuilder ? TContext : never; ``` -Defined in: [packages/db/src/query/builder/index.ts:915](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L915) +Defined in: [packages/db/src/query/builder/index.ts:1235](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L1235) ## Type Parameters diff --git a/docs/reference/type-aliases/Fn.md b/docs/reference/type-aliases/Fn.md index e79a1aca2..9e1b0a449 100644 --- a/docs/reference/type-aliases/Fn.md +++ b/docs/reference/type-aliases/Fn.md @@ -9,7 +9,7 @@ title: Fn type Fn = (...args) => any; ``` -Defined in: [packages/db/src/types.ts:67](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L67) +Defined in: [packages/db/src/types.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L69) Represents a utility function that can be attached to a collection diff --git a/docs/reference/type-aliases/FunctionalHavingRow.md b/docs/reference/type-aliases/FunctionalHavingRow.md index 0788c4e41..039184e3c 100644 --- a/docs/reference/type-aliases/FunctionalHavingRow.md +++ b/docs/reference/type-aliases/FunctionalHavingRow.md @@ -6,10 +6,10 @@ title: FunctionalHavingRow # Type Alias: FunctionalHavingRow\ ```ts -type FunctionalHavingRow = TContext["schema"] & TContext["result"] extends object ? object : object; +type FunctionalHavingRow = TContext["schema"] & TContext["hasResult"] extends true ? object : object; ``` -Defined in: [packages/db/src/query/builder/types.ts:375](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L375) +Defined in: [packages/db/src/query/builder/types.ts:483](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L483) FunctionalHavingRow - Type for the row parameter in functional having callbacks diff --git a/docs/reference/type-aliases/GetResult.md b/docs/reference/type-aliases/GetResult.md index 17bc3feda..36f204310 100644 --- a/docs/reference/type-aliases/GetResult.md +++ b/docs/reference/type-aliases/GetResult.md @@ -6,34 +6,10 @@ title: GetResult # Type Alias: GetResult\ ```ts -type GetResult = Prettify; +type GetResult = Prettify>; ``` -Defined in: [packages/db/src/query/builder/types.ts:692](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L692) - -GetResult - Determines the final result type of a query - -This type implements the logic for what a query returns based on its current state: - -**Priority Order**: -1. **Explicit Result**: If `select()` was called, use the projected type -2. **Join Query**: If joins exist, return all tables with proper optionality -3. **Single Table**: Return just the main table from `from()` - -**Examples**: -```typescript -// Single table query: -from({ users }).where(...) // → User[] - -// Join query without select: -from({ users }).leftJoin({ orders }, ...) // → { users: User, orders: Order | undefined }[] - -// Query with select: -from({ users }).select({ id: users.id, name: users.name }) // → { id: number, name: string }[] -``` - -The `Prettify` wrapper ensures clean type display in IDEs by flattening -complex intersection types into readable object types. +Defined in: [packages/db/src/query/builder/types.ts:848](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L848) ## Type Parameters diff --git a/docs/reference/type-aliases/GroupByCallback.md b/docs/reference/type-aliases/GroupByCallback.md index a716c39dc..d5f6e0d5e 100644 --- a/docs/reference/type-aliases/GroupByCallback.md +++ b/docs/reference/type-aliases/GroupByCallback.md @@ -9,7 +9,7 @@ title: GroupByCallback type GroupByCallback = (refs) => any; ``` -Defined in: [packages/db/src/query/builder/types.ts:338](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L338) +Defined in: [packages/db/src/query/builder/types.ts:446](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L446) GroupByCallback - Type for groupBy clause callback functions diff --git a/docs/reference/type-aliases/IndexConstructor.md b/docs/reference/type-aliases/IndexConstructor.md index a901d6746..0a64c46ab 100644 --- a/docs/reference/type-aliases/IndexConstructor.md +++ b/docs/reference/type-aliases/IndexConstructor.md @@ -9,7 +9,7 @@ title: IndexConstructor type IndexConstructor = (id, expression, name?, options?) => BaseIndex; ``` -Defined in: [packages/db/src/indexes/base-index.ts:214](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L214) +Defined in: [packages/db/src/indexes/base-index.ts:213](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L213) Type for index constructor diff --git a/docs/reference/type-aliases/IndexOperation-1.md b/docs/reference/type-aliases/IndexOperation-1.md new file mode 100644 index 000000000..3dbce14d1 --- /dev/null +++ b/docs/reference/type-aliases/IndexOperation-1.md @@ -0,0 +1,14 @@ +--- +id: IndexOperation +title: IndexOperation +--- + +# Type Alias: IndexOperation + +```ts +type IndexOperation = typeof comparisonFunctions[number]; +``` + +Defined in: [packages/db/src/indexes/base-index.ts:11](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L11) + +Type for index operation values diff --git a/docs/reference/type-aliases/IndexOperation.md b/docs/reference/type-aliases/IndexOperation.md index 3dbce14d1..23f84e1c0 100644 --- a/docs/reference/type-aliases/IndexOperation.md +++ b/docs/reference/type-aliases/IndexOperation.md @@ -6,9 +6,9 @@ title: IndexOperation # Type Alias: IndexOperation ```ts -type IndexOperation = typeof comparisonFunctions[number]; +type IndexOperation = readonly ["eq", "gt", "gte", "lt", "lte", "in", "like", "ilike"]; ``` Defined in: [packages/db/src/indexes/base-index.ts:11](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L11) -Type for index operation values +Operations that indexes can support, imported from available comparison functions diff --git a/docs/reference/type-aliases/IndexResolver.md b/docs/reference/type-aliases/IndexResolver.md deleted file mode 100644 index 745ac50e4..000000000 --- a/docs/reference/type-aliases/IndexResolver.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -id: IndexResolver -title: IndexResolver ---- - -# Type Alias: IndexResolver\ - -```ts -type IndexResolver = - | IndexConstructor -| () => Promise>; -``` - -Defined in: [packages/db/src/indexes/base-index.ts:225](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L225) - -Index resolver can be either a class constructor or async loader - -## Type Parameters - -### TKey - -`TKey` *extends* `string` \| `number` = `string` \| `number` diff --git a/docs/reference/type-aliases/InferCollectionType.md b/docs/reference/type-aliases/InferCollectionType.md index 0c804f43d..466fb9aeb 100644 --- a/docs/reference/type-aliases/InferCollectionType.md +++ b/docs/reference/type-aliases/InferCollectionType.md @@ -6,10 +6,10 @@ title: InferCollectionType # Type Alias: InferCollectionType\ ```ts -type InferCollectionType = T extends CollectionImpl ? TOutput : never; +type InferCollectionType = T extends CollectionImpl ? WithVirtualProps : never; ``` -Defined in: [packages/db/src/query/builder/types.ts:85](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L85) +Defined in: [packages/db/src/query/builder/types.ts:89](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L89) InferCollectionType - Extracts the TypeScript type from a CollectionImpl diff --git a/docs/reference/type-aliases/InferResultType.md b/docs/reference/type-aliases/InferResultType.md index cd318feb8..15b1f2337 100644 --- a/docs/reference/type-aliases/InferResultType.md +++ b/docs/reference/type-aliases/InferResultType.md @@ -9,7 +9,7 @@ title: InferResultType type InferResultType = TContext extends SingleResult ? GetResult | undefined : GetResult[]; ``` -Defined in: [packages/db/src/query/builder/types.ts:662](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L662) +Defined in: [packages/db/src/query/builder/types.ts:805](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L805) Utility type to infer the query result size (single row or an array) diff --git a/docs/reference/type-aliases/InferSchemaInput.md b/docs/reference/type-aliases/InferSchemaInput.md index 1e6ad08ff..c4e31890c 100644 --- a/docs/reference/type-aliases/InferSchemaInput.md +++ b/docs/reference/type-aliases/InferSchemaInput.md @@ -9,7 +9,7 @@ title: InferSchemaInput type InferSchemaInput = T extends StandardSchemaV1 ? StandardSchemaV1.InferInput extends object ? StandardSchemaV1.InferInput : Record : Record; ``` -Defined in: [packages/db/src/types.ts:56](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L56) +Defined in: [packages/db/src/types.ts:58](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L58) **`Internal`** diff --git a/docs/reference/type-aliases/InferSchemaOutput.md b/docs/reference/type-aliases/InferSchemaOutput.md index 7b170e663..e4af2dae0 100644 --- a/docs/reference/type-aliases/InferSchemaOutput.md +++ b/docs/reference/type-aliases/InferSchemaOutput.md @@ -9,7 +9,7 @@ title: InferSchemaOutput type InferSchemaOutput = T extends StandardSchemaV1 ? StandardSchemaV1.InferOutput extends object ? StandardSchemaV1.InferOutput : Record : Record; ``` -Defined in: [packages/db/src/types.ts:45](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L45) +Defined in: [packages/db/src/types.ts:47](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L47) **`Internal`** diff --git a/docs/reference/type-aliases/InitialQueryBuilder.md b/docs/reference/type-aliases/InitialQueryBuilder.md index 64a31177f..1308b07fc 100644 --- a/docs/reference/type-aliases/InitialQueryBuilder.md +++ b/docs/reference/type-aliases/InitialQueryBuilder.md @@ -9,4 +9,4 @@ title: InitialQueryBuilder type InitialQueryBuilder = Pick, "from">; ``` -Defined in: [packages/db/src/query/builder/index.ts:901](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L901) +Defined in: [packages/db/src/query/builder/index.ts:1221](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L1221) diff --git a/docs/reference/type-aliases/InputRow.md b/docs/reference/type-aliases/InputRow.md index 58fc37ce3..62bab028f 100644 --- a/docs/reference/type-aliases/InputRow.md +++ b/docs/reference/type-aliases/InputRow.md @@ -9,6 +9,6 @@ title: InputRow type InputRow = [unknown, Record]; ``` -Defined in: [packages/db/src/types.ts:749](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L749) +Defined in: [packages/db/src/types.ts:787](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L787) An input row from a collection diff --git a/docs/reference/type-aliases/InsertMutationFn.md b/docs/reference/type-aliases/InsertMutationFn.md index e78617fb5..219f71c9a 100644 --- a/docs/reference/type-aliases/InsertMutationFn.md +++ b/docs/reference/type-aliases/InsertMutationFn.md @@ -9,7 +9,7 @@ title: InsertMutationFn type InsertMutationFn = (params) => Promise; ``` -Defined in: [packages/db/src/types.ts:449](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L449) +Defined in: [packages/db/src/types.ts:471](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L471) ## Type Parameters diff --git a/docs/reference/type-aliases/InsertMutationFnParams.md b/docs/reference/type-aliases/InsertMutationFnParams.md index 9c3c5fad0..8607d1dba 100644 --- a/docs/reference/type-aliases/InsertMutationFnParams.md +++ b/docs/reference/type-aliases/InsertMutationFnParams.md @@ -9,7 +9,7 @@ title: InsertMutationFnParams type InsertMutationFnParams = object; ``` -Defined in: [packages/db/src/types.ts:432](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L432) +Defined in: [packages/db/src/types.ts:454](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L454) ## Type Parameters @@ -33,7 +33,7 @@ Defined in: [packages/db/src/types.ts:432](https://github.com/TanStack/db/blob/m collection: Collection; ``` -Defined in: [packages/db/src/types.ts:438](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L438) +Defined in: [packages/db/src/types.ts:460](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L460) *** @@ -43,4 +43,4 @@ Defined in: [packages/db/src/types.ts:438](https://github.com/TanStack/db/blob/m transaction: TransactionWithMutations; ``` -Defined in: [packages/db/src/types.ts:437](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L437) +Defined in: [packages/db/src/types.ts:459](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L459) diff --git a/docs/reference/type-aliases/JoinOnCallback.md b/docs/reference/type-aliases/JoinOnCallback.md index 60b50c32f..27ba29f3a 100644 --- a/docs/reference/type-aliases/JoinOnCallback.md +++ b/docs/reference/type-aliases/JoinOnCallback.md @@ -9,7 +9,7 @@ title: JoinOnCallback type JoinOnCallback = (refs) => any; ``` -Defined in: [packages/db/src/query/builder/types.ts:354](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L354) +Defined in: [packages/db/src/query/builder/types.ts:462](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L462) JoinOnCallback - Type for join condition callback functions diff --git a/docs/reference/type-aliases/KeyedNamespacedRow.md b/docs/reference/type-aliases/KeyedNamespacedRow.md index cfd820ed1..d5f1694b3 100644 --- a/docs/reference/type-aliases/KeyedNamespacedRow.md +++ b/docs/reference/type-aliases/KeyedNamespacedRow.md @@ -9,7 +9,7 @@ title: KeyedNamespacedRow type KeyedNamespacedRow = [unknown, NamespacedRow]; ``` -Defined in: [packages/db/src/types.ts:772](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L772) +Defined in: [packages/db/src/types.ts:810](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L810) A keyed namespaced row is a row with a key and a namespaced row This is the main representation of a row in a query pipeline diff --git a/docs/reference/type-aliases/KeyedStream.md b/docs/reference/type-aliases/KeyedStream.md index dbc41e13c..20d1aac87 100644 --- a/docs/reference/type-aliases/KeyedStream.md +++ b/docs/reference/type-aliases/KeyedStream.md @@ -9,7 +9,7 @@ title: KeyedStream type KeyedStream = IStreamBuilder; ``` -Defined in: [packages/db/src/types.ts:755](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L755) +Defined in: [packages/db/src/types.ts:793](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L793) A keyed stream is a stream of rows This is used as the inputs from a collection to a query diff --git a/docs/reference/type-aliases/LiveQueryCollectionUtils.md b/docs/reference/type-aliases/LiveQueryCollectionUtils.md index 468fa1bf5..ecb1be489 100644 --- a/docs/reference/type-aliases/LiveQueryCollectionUtils.md +++ b/docs/reference/type-aliases/LiveQueryCollectionUtils.md @@ -9,7 +9,7 @@ title: LiveQueryCollectionUtils type LiveQueryCollectionUtils = UtilsRecord & object; ``` -Defined in: [packages/db/src/query/live/collection-config-builder.ts:39](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/collection-config-builder.ts#L39) +Defined in: [packages/db/src/query/live/collection-config-builder.ts:54](https://github.com/TanStack/db/blob/main/packages/db/src/query/live/collection-config-builder.ts#L54) ## Type Declaration diff --git a/docs/reference/type-aliases/LoadSubsetFn.md b/docs/reference/type-aliases/LoadSubsetFn.md index 862a82163..c7825337d 100644 --- a/docs/reference/type-aliases/LoadSubsetFn.md +++ b/docs/reference/type-aliases/LoadSubsetFn.md @@ -9,7 +9,7 @@ title: LoadSubsetFn type LoadSubsetFn = (options) => true | Promise; ``` -Defined in: [packages/db/src/types.ts:314](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L314) +Defined in: [packages/db/src/types.ts:316](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L316) ## Parameters diff --git a/docs/reference/type-aliases/LoadSubsetOptions.md b/docs/reference/type-aliases/LoadSubsetOptions.md index 8e8cfe27c..f1b155add 100644 --- a/docs/reference/type-aliases/LoadSubsetOptions.md +++ b/docs/reference/type-aliases/LoadSubsetOptions.md @@ -9,7 +9,7 @@ title: LoadSubsetOptions type LoadSubsetOptions = object; ``` -Defined in: [packages/db/src/types.ts:285](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L285) +Defined in: [packages/db/src/types.ts:287](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L287) ## Properties @@ -19,7 +19,7 @@ Defined in: [packages/db/src/types.ts:285](https://github.com/TanStack/db/blob/m optional cursor: CursorExpressions; ``` -Defined in: [packages/db/src/types.ts:297](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L297) +Defined in: [packages/db/src/types.ts:299](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L299) Cursor expressions for cursor-based pagination. These are separate from `where` - the sync layer should combine them if using cursor-based pagination. @@ -33,7 +33,7 @@ Neither expression includes the main `where` clause. optional limit: number; ``` -Defined in: [packages/db/src/types.ts:291](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L291) +Defined in: [packages/db/src/types.ts:293](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L293) The limit of the data to load @@ -45,7 +45,7 @@ The limit of the data to load optional offset: number; ``` -Defined in: [packages/db/src/types.ts:302](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L302) +Defined in: [packages/db/src/types.ts:304](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L304) Row offset for offset-based pagination. The sync layer can use this instead of `cursor` if it prefers offset-based pagination. @@ -58,7 +58,7 @@ The sync layer can use this instead of `cursor` if it prefers offset-based pagin optional orderBy: OrderBy; ``` -Defined in: [packages/db/src/types.ts:289](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L289) +Defined in: [packages/db/src/types.ts:291](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L291) The order by clause to sort the data @@ -70,7 +70,7 @@ The order by clause to sort the data optional subscription: Subscription; ``` -Defined in: [packages/db/src/types.ts:311](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L311) +Defined in: [packages/db/src/types.ts:313](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L313) The subscription that triggered the load. Advanced sync implementations can use this for: @@ -90,6 +90,6 @@ Available when called from CollectionSubscription, may be undefined for direct c optional where: BasicExpression; ``` -Defined in: [packages/db/src/types.ts:287](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L287) +Defined in: [packages/db/src/types.ts:289](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L289) The where expression to filter the data (does NOT include cursor expressions) diff --git a/docs/reference/type-aliases/MakeOptional.md b/docs/reference/type-aliases/MakeOptional.md index 4dd594d01..122f6f993 100644 --- a/docs/reference/type-aliases/MakeOptional.md +++ b/docs/reference/type-aliases/MakeOptional.md @@ -9,7 +9,7 @@ title: MakeOptional type MakeOptional = Omit & Partial>; ``` -Defined in: [packages/db/src/types.ts:958](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L958) +Defined in: [packages/db/src/types.ts:998](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L998) ## Type Parameters diff --git a/docs/reference/type-aliases/MaybeSingleResult.md b/docs/reference/type-aliases/MaybeSingleResult.md index d86ed4fd0..238da7bd4 100644 --- a/docs/reference/type-aliases/MaybeSingleResult.md +++ b/docs/reference/type-aliases/MaybeSingleResult.md @@ -9,7 +9,7 @@ title: MaybeSingleResult type MaybeSingleResult = object; ``` -Defined in: [packages/db/src/types.ts:727](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L727) +Defined in: [packages/db/src/types.ts:764](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L764) ## Properties @@ -19,6 +19,6 @@ Defined in: [packages/db/src/types.ts:727](https://github.com/TanStack/db/blob/m optional singleResult: true; ``` -Defined in: [packages/db/src/types.ts:731](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L731) +Defined in: [packages/db/src/types.ts:768](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L768) If enabled the collection will return a single object instead of an array diff --git a/docs/reference/type-aliases/MergeContextForJoinCallback.md b/docs/reference/type-aliases/MergeContextForJoinCallback.md index f19198080..b675c42d1 100644 --- a/docs/reference/type-aliases/MergeContextForJoinCallback.md +++ b/docs/reference/type-aliases/MergeContextForJoinCallback.md @@ -6,10 +6,10 @@ title: MergeContextForJoinCallback # Type Alias: MergeContextForJoinCallback\ ```ts -type MergeContextForJoinCallback = object; +type MergeContextForJoinCallback = object & PreserveHasResultFlag; ``` -Defined in: [packages/db/src/query/builder/types.ts:821](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L821) +Defined in: [packages/db/src/query/builder/types.ts:1005](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L1005) MergeContextForJoinCallback - Special context for join condition callbacks @@ -37,17 +37,7 @@ Optionality is only applied to the result AFTER the join logic executes. The simple intersection (&) merges schemas without any optionality transformation. -## Type Parameters - -### TContext - -`TContext` *extends* [`Context`](../interfaces/Context.md) - -### TNewSchema - -`TNewSchema` *extends* [`ContextSchema`](ContextSchema.md) - -## Properties +## Type Declaration ### baseSchema @@ -55,54 +45,42 @@ The simple intersection (&) merges schemas without any optionality transformatio baseSchema: TContext["baseSchema"]; ``` -Defined in: [packages/db/src/query/builder/types.ts:825](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L825) - -*** - ### fromSourceName ```ts fromSourceName: TContext["fromSourceName"]; ``` -Defined in: [packages/db/src/query/builder/types.ts:828](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L828) - -*** - ### hasJoins ```ts hasJoins: true; ``` -Defined in: [packages/db/src/query/builder/types.ts:829](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L829) - -*** - ### joinTypes ```ts joinTypes: TContext["joinTypes"] extends Record ? TContext["joinTypes"] : object; ``` -Defined in: [packages/db/src/query/builder/types.ts:830](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L830) - -*** - ### result ```ts result: TContext["result"]; ``` -Defined in: [packages/db/src/query/builder/types.ts:833](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L833) - -*** - ### schema ```ts schema: TContext["schema"] & TNewSchema; ``` -Defined in: [packages/db/src/query/builder/types.ts:827](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L827) +## Type Parameters + +### TContext + +`TContext` *extends* [`Context`](../interfaces/Context.md) + +### TNewSchema + +`TNewSchema` *extends* [`ContextSchema`](ContextSchema.md) diff --git a/docs/reference/type-aliases/MergeContextWithJoinType.md b/docs/reference/type-aliases/MergeContextWithJoinType.md index a12cf3ba2..983e84718 100644 --- a/docs/reference/type-aliases/MergeContextWithJoinType.md +++ b/docs/reference/type-aliases/MergeContextWithJoinType.md @@ -6,10 +6,10 @@ title: MergeContextWithJoinType # Type Alias: MergeContextWithJoinType\ ```ts -type MergeContextWithJoinType = object & PreserveSingleResultFlag; +type MergeContextWithJoinType = object & PreserveSingleResultFlag & PreserveHasResultFlag; ``` -Defined in: [packages/db/src/query/builder/types.ts:587](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L587) +Defined in: [packages/db/src/query/builder/types.ts:729](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L729) MergeContextWithJoinType - Creates a new context after a join operation diff --git a/docs/reference/type-aliases/MutationFn.md b/docs/reference/type-aliases/MutationFn.md index 33ff9dcf1..647bb2cc4 100644 --- a/docs/reference/type-aliases/MutationFn.md +++ b/docs/reference/type-aliases/MutationFn.md @@ -9,7 +9,7 @@ title: MutationFn type MutationFn = (params) => Promise; ``` -Defined in: [packages/db/src/types.ts:127](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L127) +Defined in: [packages/db/src/types.ts:129](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L129) ## Type Parameters diff --git a/docs/reference/type-aliases/MutationFnParams.md b/docs/reference/type-aliases/MutationFnParams.md index 7df30d800..d3380370c 100644 --- a/docs/reference/type-aliases/MutationFnParams.md +++ b/docs/reference/type-aliases/MutationFnParams.md @@ -9,7 +9,7 @@ title: MutationFnParams type MutationFnParams = object; ``` -Defined in: [packages/db/src/types.ts:123](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L123) +Defined in: [packages/db/src/types.ts:125](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L125) Configuration options for creating a new transaction @@ -27,4 +27,4 @@ Configuration options for creating a new transaction transaction: TransactionWithMutations; ``` -Defined in: [packages/db/src/types.ts:124](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L124) +Defined in: [packages/db/src/types.ts:126](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L126) diff --git a/docs/reference/type-aliases/NamespacedAndKeyedStream.md b/docs/reference/type-aliases/NamespacedAndKeyedStream.md index 4c952ad84..c7d5479c9 100644 --- a/docs/reference/type-aliases/NamespacedAndKeyedStream.md +++ b/docs/reference/type-aliases/NamespacedAndKeyedStream.md @@ -9,7 +9,7 @@ title: NamespacedAndKeyedStream type NamespacedAndKeyedStream = IStreamBuilder; ``` -Defined in: [packages/db/src/types.ts:779](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L779) +Defined in: [packages/db/src/types.ts:817](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L817) A namespaced and keyed stream is a stream of rows This is used throughout a query pipeline and as the output from a query without diff --git a/docs/reference/type-aliases/NamespacedRow.md b/docs/reference/type-aliases/NamespacedRow.md index 2d7acd058..47cfc5e99 100644 --- a/docs/reference/type-aliases/NamespacedRow.md +++ b/docs/reference/type-aliases/NamespacedRow.md @@ -9,6 +9,6 @@ title: NamespacedRow type NamespacedRow = Record>; ``` -Defined in: [packages/db/src/types.ts:766](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L766) +Defined in: [packages/db/src/types.ts:804](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L804) A namespaced row is a row withing a pipeline that had each table wrapped in its alias diff --git a/docs/reference/type-aliases/NonEmptyArray.md b/docs/reference/type-aliases/NonEmptyArray.md index 3ff5d7dfa..6b43145f5 100644 --- a/docs/reference/type-aliases/NonEmptyArray.md +++ b/docs/reference/type-aliases/NonEmptyArray.md @@ -9,7 +9,7 @@ title: NonEmptyArray type NonEmptyArray = [T, ...T[]]; ``` -Defined in: [packages/db/src/types.ts:134](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L134) +Defined in: [packages/db/src/types.ts:136](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L136) Represents a non-empty array (at least one element) diff --git a/docs/reference/type-aliases/NonSingleResult.md b/docs/reference/type-aliases/NonSingleResult.md index bd198e148..b4ecf311f 100644 --- a/docs/reference/type-aliases/NonSingleResult.md +++ b/docs/reference/type-aliases/NonSingleResult.md @@ -9,7 +9,7 @@ title: NonSingleResult type NonSingleResult = object; ``` -Defined in: [packages/db/src/types.ts:723](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L723) +Defined in: [packages/db/src/types.ts:760](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L760) ## Properties @@ -19,4 +19,4 @@ Defined in: [packages/db/src/types.ts:723](https://github.com/TanStack/db/blob/m optional singleResult: never; ``` -Defined in: [packages/db/src/types.ts:724](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L724) +Defined in: [packages/db/src/types.ts:761](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L761) diff --git a/docs/reference/type-aliases/OperationType.md b/docs/reference/type-aliases/OperationType.md index 2f9b1f6c7..f6bdc3117 100644 --- a/docs/reference/type-aliases/OperationType.md +++ b/docs/reference/type-aliases/OperationType.md @@ -9,4 +9,4 @@ title: OperationType type OperationType = "insert" | "update" | "delete"; ``` -Defined in: [packages/db/src/types.ts:203](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L203) +Defined in: [packages/db/src/types.ts:205](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L205) diff --git a/docs/reference/type-aliases/OperatorName.md b/docs/reference/type-aliases/OperatorName.md index 6535be23f..92c072d00 100644 --- a/docs/reference/type-aliases/OperatorName.md +++ b/docs/reference/type-aliases/OperatorName.md @@ -9,4 +9,4 @@ title: OperatorName type OperatorName = typeof operators[number]; ``` -Defined in: [packages/db/src/query/builder/functions.ts:378](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L378) +Defined in: [packages/db/src/query/builder/functions.ts:437](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L437) diff --git a/docs/reference/type-aliases/OptimisticChangeMessage.md b/docs/reference/type-aliases/OptimisticChangeMessage.md index 05fa24929..a08950003 100644 --- a/docs/reference/type-aliases/OptimisticChangeMessage.md +++ b/docs/reference/type-aliases/OptimisticChangeMessage.md @@ -11,7 +11,7 @@ type OptimisticChangeMessage = | DeleteKeyMessage & object; ``` -Defined in: [packages/db/src/types.ts:380](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L380) +Defined in: [packages/db/src/types.ts:402](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L402) ## Type Parameters diff --git a/docs/reference/type-aliases/OrderByCallback.md b/docs/reference/type-aliases/OrderByCallback.md index fa78b20dc..b58fde0d1 100644 --- a/docs/reference/type-aliases/OrderByCallback.md +++ b/docs/reference/type-aliases/OrderByCallback.md @@ -9,7 +9,7 @@ title: OrderByCallback type OrderByCallback = (refs) => any; ``` -Defined in: [packages/db/src/query/builder/types.ts:302](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L302) +Defined in: [packages/db/src/query/builder/types.ts:410](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L410) OrderByCallback - Type for orderBy clause callback functions diff --git a/docs/reference/type-aliases/Prettify.md b/docs/reference/type-aliases/Prettify.md index c55eea7fb..673257fd9 100644 --- a/docs/reference/type-aliases/Prettify.md +++ b/docs/reference/type-aliases/Prettify.md @@ -9,7 +9,7 @@ title: Prettify type Prettify = { [K in keyof T]: T[K] } & object; ``` -Defined in: [packages/db/src/query/builder/types.ts:859](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L859) +Defined in: [packages/db/src/query/builder/types.ts:1044](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L1044) Prettify - Utility type for clean IDE display diff --git a/docs/reference/type-aliases/QueryBuilder.md b/docs/reference/type-aliases/QueryBuilder.md index a487fa939..060999bb6 100644 --- a/docs/reference/type-aliases/QueryBuilder.md +++ b/docs/reference/type-aliases/QueryBuilder.md @@ -9,7 +9,7 @@ title: QueryBuilder type QueryBuilder = Omit, "from" | "_getQuery">; ``` -Defined in: [packages/db/src/query/builder/index.ts:905](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L905) +Defined in: [packages/db/src/query/builder/index.ts:1225](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L1225) ## Type Parameters diff --git a/docs/reference/type-aliases/QueryResult.md b/docs/reference/type-aliases/QueryResult.md index f3e012b7a..26cecaf63 100644 --- a/docs/reference/type-aliases/QueryResult.md +++ b/docs/reference/type-aliases/QueryResult.md @@ -9,7 +9,7 @@ title: QueryResult type QueryResult = GetResult>; ``` -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) +Defined in: [packages/db/src/query/builder/index.ts:1243](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L1243) ## Type Parameters diff --git a/docs/reference/type-aliases/Ref.md b/docs/reference/type-aliases/Ref.md index 8c8015219..fce38d02f 100644 --- a/docs/reference/type-aliases/Ref.md +++ b/docs/reference/type-aliases/Ref.md @@ -6,10 +6,10 @@ title: Ref # Type Alias: Ref\ ```ts -type Ref = { [K in keyof T]: IsNonExactOptional extends true ? IsNonExactNullable extends true ? IsPlainObject> extends true ? Ref, Nullable> | undefined : RefLeaf, Nullable> | undefined : IsPlainObject> extends true ? Ref, Nullable> | undefined : RefLeaf, Nullable> | undefined : IsNonExactNullable extends true ? IsPlainObject> extends true ? Ref, Nullable> | null : RefLeaf, Nullable> | null : IsPlainObject extends true ? Ref : RefLeaf } & RefLeaf; +type Ref = { [K in keyof T]: IsNonExactOptional extends true ? IsNonExactNullable extends true ? IsPlainObject> extends true ? Ref, Nullable> | undefined : RefLeaf, Nullable> | undefined : IsPlainObject> extends true ? Ref, Nullable> | undefined : RefLeaf, Nullable> | undefined : IsNonExactNullable extends true ? IsPlainObject> extends true ? Ref, Nullable> | null : RefLeaf, Nullable> | null : IsPlainObject extends true ? Ref : RefLeaf } & RefLeaf & VirtualPropsRef; ``` -Defined in: [packages/db/src/query/builder/types.ts:502](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L502) +Defined in: [packages/db/src/query/builder/types.ts:639](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L639) Ref - The user-facing ref interface for the query builder @@ -23,12 +23,18 @@ join side (left/right/full). When `true`, the `Nullable` flag propagates through all nested property accesses, ensuring the result type includes `| undefined` for all fields accessed through this ref. +Includes virtual properties ($synced, $origin, $key, $collectionId) for +querying on sync status and row metadata. + Example usage: ```typescript -// Non-nullable ref (inner join or from table): -select(({ user }) => ({ name: user.name })) // result: string +// Clean interface - no internal properties visible +const users: Ref<{ id: number; profile?: { bio: string } }> = { ... } +users.id // Ref - clean display +users.profile?.bio // Ref - nested optional access works +users.$synced // RefLeaf - virtual property access -// Nullable ref (left join right side): +// Nullable ref (left/right/full join side): select(({ dept }) => ({ name: dept.name })) // result: string | undefined // Spread operations work cleanly: diff --git a/docs/reference/type-aliases/RefsForContext.md b/docs/reference/type-aliases/RefsForContext.md index 959f47f3d..3476398e7 100644 --- a/docs/reference/type-aliases/RefsForContext.md +++ b/docs/reference/type-aliases/RefsForContext.md @@ -6,10 +6,10 @@ title: RefsForContext # Type Alias: RefsForContext\ ```ts -type RefsForContext = { [K in keyof TContext["schema"]]: IsNonExactOptional extends true ? IsNonExactNullable extends true ? Ref, true> : Ref, true> : IsNonExactNullable extends true ? Ref, true> : Ref } & TContext["result"] extends object ? object : object; +type RefsForContext = { [K in keyof TContext["schema"]]: IsNonExactOptional extends true ? IsNonExactNullable extends true ? Ref, true> : Ref, true> : IsNonExactNullable extends true ? Ref, true> : Ref } & TContext["hasResult"] extends true ? object : object; ``` -Defined in: [packages/db/src/query/builder/types.ts:394](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L394) +Defined in: [packages/db/src/query/builder/types.ts:502](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L502) RefsForContext - Creates ref proxies for all tables/collections in a query context diff --git a/docs/reference/type-aliases/ResolveTransactionChanges.md b/docs/reference/type-aliases/ResolveTransactionChanges.md index fa6a413cb..df2201ee8 100644 --- a/docs/reference/type-aliases/ResolveTransactionChanges.md +++ b/docs/reference/type-aliases/ResolveTransactionChanges.md @@ -9,7 +9,7 @@ title: ResolveTransactionChanges type ResolveTransactionChanges = TOperation extends "delete" ? T : Partial; ``` -Defined in: [packages/db/src/types.ts:80](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L80) +Defined in: [packages/db/src/types.ts:82](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L82) ## Type Parameters diff --git a/docs/reference/type-aliases/ResultStream.md b/docs/reference/type-aliases/ResultStream.md index 543f601ca..dc50b1c69 100644 --- a/docs/reference/type-aliases/ResultStream.md +++ b/docs/reference/type-aliases/ResultStream.md @@ -9,7 +9,7 @@ title: ResultStream type ResultStream = IStreamBuilder<[unknown, [any, string | undefined]]>; ``` -Defined in: [packages/db/src/types.ts:761](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L761) +Defined in: [packages/db/src/types.ts:799](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L799) Result stream type representing the output of compiled queries Always returns [key, [result, orderByIndex]] where orderByIndex is undefined for unordered queries diff --git a/docs/reference/type-aliases/ResultTypeFromSelect.md b/docs/reference/type-aliases/ResultTypeFromSelect.md index 159c94170..dd7e568aa 100644 --- a/docs/reference/type-aliases/ResultTypeFromSelect.md +++ b/docs/reference/type-aliases/ResultTypeFromSelect.md @@ -6,10 +6,10 @@ title: ResultTypeFromSelect # Type Alias: ResultTypeFromSelect\ ```ts -type ResultTypeFromSelect = WithoutRefBrand extends true ? ExtractExpressionType : TSelectObject[K] extends Ref ? ExtractRef : TSelectObject[K] extends RefLeaf ? IsNullableRef extends true ? T | undefined : T : TSelectObject[K] extends RefLeaf | undefined ? T | undefined : TSelectObject[K] extends RefLeaf | null ? IsNullableRef> extends true ? T | null | undefined : T | null : TSelectObject[K] extends Ref<(...)> | undefined ? ExtractRef<(...)> | undefined : (...)[(...)] extends (...) | (...) ? (...) | (...) : (...) extends (...) ? (...) : (...) }>>; +type ResultTypeFromSelect = IsAny extends true ? any : WithoutRefBrand extends true ? ExtractExpressionType : TSelectObject[K] extends ToArrayWrapper ? T[] : TSelectObject[K] extends ConcatToArrayWrapper ? string : TSelectObject[K] extends QueryBuilder ? Collection> : TSelectObject[K] extends Ref ? ExtractRef<(...)[(...)]> : (...)[(...)] extends RefLeaf<(...)> ? (...) extends (...) ? (...) : (...) : (...) extends (...) ? (...) : (...) }>>; ``` -Defined in: [packages/db/src/query/builder/types.ts:226](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L226) +Defined in: [packages/db/src/query/builder/types.ts:309](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L309) ResultTypeFromSelect - Infers the result type from a select object diff --git a/docs/reference/type-aliases/Row.md b/docs/reference/type-aliases/Row.md index 4e9a7cff1..c2039a5ed 100644 --- a/docs/reference/type-aliases/Row.md +++ b/docs/reference/type-aliases/Row.md @@ -9,7 +9,7 @@ title: Row type Row = Record>; ``` -Defined in: [packages/db/src/types.ts:201](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L201) +Defined in: [packages/db/src/types.ts:203](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L203) ## Type Parameters diff --git a/docs/reference/type-aliases/SchemaFromSource.md b/docs/reference/type-aliases/SchemaFromSource.md index ee81b1c0e..35569f09d 100644 --- a/docs/reference/type-aliases/SchemaFromSource.md +++ b/docs/reference/type-aliases/SchemaFromSource.md @@ -9,7 +9,7 @@ title: SchemaFromSource type SchemaFromSource = Prettify<{ [K in keyof T]: T[K] extends CollectionImpl ? InferCollectionType : T[K] extends QueryBuilder ? GetResult : never }>; ``` -Defined in: [packages/db/src/query/builder/types.ts:98](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L98) +Defined in: [packages/db/src/query/builder/types.ts:104](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L104) SchemaFromSource - Converts a Source definition into a ContextSchema diff --git a/docs/reference/type-aliases/SelectObject.md b/docs/reference/type-aliases/SelectObject.md index b3ccc1877..61ebb3124 100644 --- a/docs/reference/type-aliases/SelectObject.md +++ b/docs/reference/type-aliases/SelectObject.md @@ -9,7 +9,7 @@ title: SelectObject type SelectObject = T; ``` -Defined in: [packages/db/src/query/builder/types.ts:188](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L188) +Defined in: [packages/db/src/query/builder/types.ts:208](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L208) SelectObject - Wrapper type for select clause objects diff --git a/docs/reference/type-aliases/SingleResult.md b/docs/reference/type-aliases/SingleResult.md index 2ba7a0f10..c12442b35 100644 --- a/docs/reference/type-aliases/SingleResult.md +++ b/docs/reference/type-aliases/SingleResult.md @@ -9,7 +9,7 @@ title: SingleResult type SingleResult = object; ``` -Defined in: [packages/db/src/types.ts:719](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L719) +Defined in: [packages/db/src/types.ts:756](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L756) ## Properties @@ -19,4 +19,4 @@ Defined in: [packages/db/src/types.ts:719](https://github.com/TanStack/db/blob/m singleResult: true; ``` -Defined in: [packages/db/src/types.ts:720](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L720) +Defined in: [packages/db/src/types.ts:757](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L757) diff --git a/docs/reference/type-aliases/Source.md b/docs/reference/type-aliases/Source.md index 3d5b59b01..9c797516a 100644 --- a/docs/reference/type-aliases/Source.md +++ b/docs/reference/type-aliases/Source.md @@ -9,7 +9,7 @@ title: Source type Source = object; ``` -Defined in: [packages/db/src/query/builder/types.ts:75](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L75) +Defined in: [packages/db/src/query/builder/types.ts:79](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L79) Source - Input definition for query builder `from()` clause diff --git a/docs/reference/type-aliases/StandardSchema.md b/docs/reference/type-aliases/StandardSchema.md index dd88681a5..552e45761 100644 --- a/docs/reference/type-aliases/StandardSchema.md +++ b/docs/reference/type-aliases/StandardSchema.md @@ -9,7 +9,7 @@ title: StandardSchema type StandardSchema = StandardSchemaV1 & object; ``` -Defined in: [packages/db/src/types.ts:397](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L397) +Defined in: [packages/db/src/types.ts:419](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L419) The Standard Schema interface. This follows the standard-schema specification: https://github.com/standard-schema/standard-schema diff --git a/docs/reference/type-aliases/StandardSchemaAlias.md b/docs/reference/type-aliases/StandardSchemaAlias.md index 423e619e5..b7efab5ee 100644 --- a/docs/reference/type-aliases/StandardSchemaAlias.md +++ b/docs/reference/type-aliases/StandardSchemaAlias.md @@ -9,7 +9,7 @@ title: StandardSchemaAlias type StandardSchemaAlias = StandardSchema; ``` -Defined in: [packages/db/src/types.ts:409](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L409) +Defined in: [packages/db/src/types.ts:431](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L431) Type alias for StandardSchema diff --git a/docs/reference/type-aliases/StringCollationConfig.md b/docs/reference/type-aliases/StringCollationConfig.md index 7ac99e3ab..d0b89184e 100644 --- a/docs/reference/type-aliases/StringCollationConfig.md +++ b/docs/reference/type-aliases/StringCollationConfig.md @@ -17,7 +17,7 @@ type StringCollationConfig = }; ``` -Defined in: [packages/db/src/types.ts:30](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L30) +Defined in: [packages/db/src/types.ts:32](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L32) StringSortOpts - Options for string sorting behavior diff --git a/docs/reference/type-aliases/SubscriptionEvents.md b/docs/reference/type-aliases/SubscriptionEvents.md index 5361b9956..15b3c1181 100644 --- a/docs/reference/type-aliases/SubscriptionEvents.md +++ b/docs/reference/type-aliases/SubscriptionEvents.md @@ -9,7 +9,7 @@ title: SubscriptionEvents type SubscriptionEvents = object; ``` -Defined in: [packages/db/src/types.ts:241](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L241) +Defined in: [packages/db/src/types.ts:243](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L243) All subscription events @@ -21,7 +21,7 @@ All subscription events status:change: SubscriptionStatusChangeEvent; ``` -Defined in: [packages/db/src/types.ts:242](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L242) +Defined in: [packages/db/src/types.ts:244](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L244) *** @@ -31,7 +31,7 @@ Defined in: [packages/db/src/types.ts:242](https://github.com/TanStack/db/blob/m status:loadingSubset: SubscriptionStatusEvent<"loadingSubset">; ``` -Defined in: [packages/db/src/types.ts:244](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L244) +Defined in: [packages/db/src/types.ts:246](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L246) *** @@ -41,7 +41,7 @@ Defined in: [packages/db/src/types.ts:244](https://github.com/TanStack/db/blob/m status:ready: SubscriptionStatusEvent<"ready">; ``` -Defined in: [packages/db/src/types.ts:243](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L243) +Defined in: [packages/db/src/types.ts:245](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L245) *** @@ -51,4 +51,4 @@ Defined in: [packages/db/src/types.ts:243](https://github.com/TanStack/db/blob/m unsubscribed: SubscriptionUnsubscribedEvent; ``` -Defined in: [packages/db/src/types.ts:245](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L245) +Defined in: [packages/db/src/types.ts:247](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L247) diff --git a/docs/reference/type-aliases/SubscriptionStatus.md b/docs/reference/type-aliases/SubscriptionStatus.md index 3b35a5491..32218fdc9 100644 --- a/docs/reference/type-aliases/SubscriptionStatus.md +++ b/docs/reference/type-aliases/SubscriptionStatus.md @@ -9,6 +9,6 @@ title: SubscriptionStatus type SubscriptionStatus = "ready" | "loadingSubset"; ``` -Defined in: [packages/db/src/types.ts:208](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L208) +Defined in: [packages/db/src/types.ts:210](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L210) Subscription status values diff --git a/docs/reference/type-aliases/SyncConfigRes.md b/docs/reference/type-aliases/SyncConfigRes.md index e719a0a1d..f9e77f546 100644 --- a/docs/reference/type-aliases/SyncConfigRes.md +++ b/docs/reference/type-aliases/SyncConfigRes.md @@ -9,7 +9,7 @@ title: SyncConfigRes type SyncConfigRes = object; ``` -Defined in: [packages/db/src/types.ts:320](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L320) +Defined in: [packages/db/src/types.ts:322](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L322) ## Properties @@ -19,7 +19,7 @@ Defined in: [packages/db/src/types.ts:320](https://github.com/TanStack/db/blob/m optional cleanup: CleanupFn; ``` -Defined in: [packages/db/src/types.ts:321](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L321) +Defined in: [packages/db/src/types.ts:323](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L323) *** @@ -29,7 +29,7 @@ Defined in: [packages/db/src/types.ts:321](https://github.com/TanStack/db/blob/m optional loadSubset: LoadSubsetFn; ``` -Defined in: [packages/db/src/types.ts:322](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L322) +Defined in: [packages/db/src/types.ts:324](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L324) *** @@ -39,4 +39,4 @@ Defined in: [packages/db/src/types.ts:322](https://github.com/TanStack/db/blob/m optional unloadSubset: UnloadSubsetFn; ``` -Defined in: [packages/db/src/types.ts:323](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L323) +Defined in: [packages/db/src/types.ts:325](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L325) diff --git a/docs/reference/type-aliases/SyncMode.md b/docs/reference/type-aliases/SyncMode.md index 920cf35c7..b1222c800 100644 --- a/docs/reference/type-aliases/SyncMode.md +++ b/docs/reference/type-aliases/SyncMode.md @@ -9,4 +9,4 @@ title: SyncMode type SyncMode = "eager" | "on-demand"; ``` -Defined in: [packages/db/src/types.ts:497](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L497) +Defined in: [packages/db/src/types.ts:519](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L519) diff --git a/docs/reference/type-aliases/TransactionState.md b/docs/reference/type-aliases/TransactionState.md index 2558a48d3..efcb963a6 100644 --- a/docs/reference/type-aliases/TransactionState.md +++ b/docs/reference/type-aliases/TransactionState.md @@ -9,4 +9,4 @@ title: TransactionState type TransactionState = "pending" | "persisting" | "completed" | "failed"; ``` -Defined in: [packages/db/src/types.ts:62](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L62) +Defined in: [packages/db/src/types.ts:64](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L64) diff --git a/docs/reference/type-aliases/TransactionWithMutations.md b/docs/reference/type-aliases/TransactionWithMutations.md index e6e1dc979..cb00d3556 100644 --- a/docs/reference/type-aliases/TransactionWithMutations.md +++ b/docs/reference/type-aliases/TransactionWithMutations.md @@ -9,7 +9,7 @@ title: TransactionWithMutations type TransactionWithMutations = Omit, "mutations"> & object; ``` -Defined in: [packages/db/src/types.ts:140](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L140) +Defined in: [packages/db/src/types.ts:142](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L142) Utility type for a Transaction with at least one mutation This is used internally by the Transaction.commit method diff --git a/docs/reference/type-aliases/UnloadSubsetFn.md b/docs/reference/type-aliases/UnloadSubsetFn.md index de8d803bb..bbb033adb 100644 --- a/docs/reference/type-aliases/UnloadSubsetFn.md +++ b/docs/reference/type-aliases/UnloadSubsetFn.md @@ -9,7 +9,7 @@ title: UnloadSubsetFn type UnloadSubsetFn = (options) => void; ``` -Defined in: [packages/db/src/types.ts:316](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L316) +Defined in: [packages/db/src/types.ts:318](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L318) ## Parameters diff --git a/docs/reference/type-aliases/UpdateMutationFn.md b/docs/reference/type-aliases/UpdateMutationFn.md index d32142d44..06d9837d0 100644 --- a/docs/reference/type-aliases/UpdateMutationFn.md +++ b/docs/reference/type-aliases/UpdateMutationFn.md @@ -9,7 +9,7 @@ title: UpdateMutationFn type UpdateMutationFn = (params) => Promise; ``` -Defined in: [packages/db/src/types.ts:456](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L456) +Defined in: [packages/db/src/types.ts:478](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L478) ## Type Parameters diff --git a/docs/reference/type-aliases/UpdateMutationFnParams.md b/docs/reference/type-aliases/UpdateMutationFnParams.md index 7180021f6..ea80ff58d 100644 --- a/docs/reference/type-aliases/UpdateMutationFnParams.md +++ b/docs/reference/type-aliases/UpdateMutationFnParams.md @@ -9,7 +9,7 @@ title: UpdateMutationFnParams type UpdateMutationFnParams = object; ``` -Defined in: [packages/db/src/types.ts:423](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L423) +Defined in: [packages/db/src/types.ts:445](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L445) ## Type Parameters @@ -33,7 +33,7 @@ Defined in: [packages/db/src/types.ts:423](https://github.com/TanStack/db/blob/m collection: Collection; ``` -Defined in: [packages/db/src/types.ts:429](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L429) +Defined in: [packages/db/src/types.ts:451](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L451) *** @@ -43,4 +43,4 @@ Defined in: [packages/db/src/types.ts:429](https://github.com/TanStack/db/blob/m transaction: TransactionWithMutations; ``` -Defined in: [packages/db/src/types.ts:428](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L428) +Defined in: [packages/db/src/types.ts:450](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L450) diff --git a/docs/reference/type-aliases/UtilsRecord.md b/docs/reference/type-aliases/UtilsRecord.md index 2a0a44b13..38e7e46f8 100644 --- a/docs/reference/type-aliases/UtilsRecord.md +++ b/docs/reference/type-aliases/UtilsRecord.md @@ -9,6 +9,6 @@ title: UtilsRecord type UtilsRecord = Record; ``` -Defined in: [packages/db/src/types.ts:72](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L72) +Defined in: [packages/db/src/types.ts:74](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L74) A record of utilities (functions or getters) that can be attached to a collection diff --git a/docs/reference/type-aliases/VirtualOrigin.md b/docs/reference/type-aliases/VirtualOrigin.md new file mode 100644 index 000000000..5c47abb03 --- /dev/null +++ b/docs/reference/type-aliases/VirtualOrigin.md @@ -0,0 +1,22 @@ +--- +id: VirtualOrigin +title: VirtualOrigin +--- + +# Type Alias: VirtualOrigin + +```ts +type VirtualOrigin = "local" | "remote"; +``` + +Defined in: [packages/db/src/virtual-props.ts:22](https://github.com/TanStack/db/blob/main/packages/db/src/virtual-props.ts#L22) + +Origin of the last confirmed change to a row, from the current client's perspective. + +- `'local'`: The change originated from this client (e.g., a mutation made here) +- `'remote'`: The change was received via sync from another client/server + +Note: This reflects the client's perspective, not the original creator. +User A creates order → $origin = 'local' on User A's client +Order syncs to server +User B receives order → $origin = 'remote' on User B's client diff --git a/docs/reference/type-aliases/WhereCallback.md b/docs/reference/type-aliases/WhereCallback.md index 2905e7677..2f556c721 100644 --- a/docs/reference/type-aliases/WhereCallback.md +++ b/docs/reference/type-aliases/WhereCallback.md @@ -9,7 +9,7 @@ title: WhereCallback type WhereCallback = (refs) => any; ``` -Defined in: [packages/db/src/query/builder/types.ts:123](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L123) +Defined in: [packages/db/src/query/builder/types.ts:129](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L129) WhereCallback - Type for where/having clause callback functions diff --git a/docs/reference/type-aliases/WithResult.md b/docs/reference/type-aliases/WithResult.md index e0513937a..862a84cf2 100644 --- a/docs/reference/type-aliases/WithResult.md +++ b/docs/reference/type-aliases/WithResult.md @@ -6,10 +6,10 @@ title: WithResult # Type Alias: WithResult\ ```ts -type WithResult = Prettify & object>; +type WithResult = Prettify & object>; ``` -Defined in: [packages/db/src/query/builder/types.ts:850](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L850) +Defined in: [packages/db/src/query/builder/types.ts:1034](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/types.ts#L1034) WithResult - Updates a context with a new result type after select() diff --git a/docs/reference/type-aliases/WithVirtualProps.md b/docs/reference/type-aliases/WithVirtualProps.md new file mode 100644 index 000000000..7a8b21aea --- /dev/null +++ b/docs/reference/type-aliases/WithVirtualProps.md @@ -0,0 +1,36 @@ +--- +id: WithVirtualProps +title: WithVirtualProps +--- + +# Type Alias: WithVirtualProps\ + +```ts +type WithVirtualProps = T & VirtualRowProps; +``` + +Defined in: [packages/db/src/virtual-props.ts:112](https://github.com/TanStack/db/blob/main/packages/db/src/virtual-props.ts#L112) + +Adds virtual properties to a row type. + +## Type Parameters + +### T + +`T` *extends* `object` + +The base row type + +### TKey + +`TKey` *extends* `string` \| `number` = `string` \| `number` + +The type of the row's key + +## Example + +```typescript +type User = { id: string; name: string } +type UserWithVirtual = WithVirtualProps +// { id: string; name: string; $synced: boolean; $origin: 'local' | 'remote'; $key: string; $collectionId: string } +``` diff --git a/docs/reference/type-aliases/WithoutVirtualProps.md b/docs/reference/type-aliases/WithoutVirtualProps.md new file mode 100644 index 000000000..f7c3d864e --- /dev/null +++ b/docs/reference/type-aliases/WithoutVirtualProps.md @@ -0,0 +1,31 @@ +--- +id: WithoutVirtualProps +title: WithoutVirtualProps +--- + +# Type Alias: WithoutVirtualProps\ + +```ts +type WithoutVirtualProps = Omit; +``` + +Defined in: [packages/db/src/virtual-props.ts:130](https://github.com/TanStack/db/blob/main/packages/db/src/virtual-props.ts#L130) + +Extracts the base type from a type that may have virtual properties. +Useful when you need to work with the raw data without virtual properties. + +## Type Parameters + +### T + +`T` + +The type that may include virtual properties + +## Example + +```typescript +type UserWithVirtual = { id: string; name: string; $synced: boolean; $origin: 'local' | 'remote' } +type User = WithoutVirtualProps +// { id: string; name: string } +``` diff --git a/docs/reference/type-aliases/WritableDeep.md b/docs/reference/type-aliases/WritableDeep.md index 204535b19..41c352f9d 100644 --- a/docs/reference/type-aliases/WritableDeep.md +++ b/docs/reference/type-aliases/WritableDeep.md @@ -9,7 +9,7 @@ title: WritableDeep type WritableDeep = T extends BuiltIns ? T : T extends (...arguments_) => unknown ? object extends WritableObjectDeep ? T : HasMultipleCallSignatures extends true ? T : (...arguments_) => ReturnType & WritableObjectDeep : T extends ReadonlyMap ? WritableMapDeep : T extends ReadonlySet ? WritableSetDeep : T extends ReadonlyArray ? WritableArrayDeep : T extends object ? WritableObjectDeep : unknown; ``` -Defined in: [packages/db/src/types.ts:939](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L939) +Defined in: [packages/db/src/types.ts:979](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L979) ## Type Parameters diff --git a/docs/reference/variables/IndexOperation.md b/docs/reference/variables/IndexOperation.md deleted file mode 100644 index e0ec16ffa..000000000 --- a/docs/reference/variables/IndexOperation.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -id: IndexOperation -title: IndexOperation ---- - -# Variable: IndexOperation - -```ts -const IndexOperation: readonly ["eq", "gt", "gte", "lt", "lte", "in", "like", "ilike"] = comparisonFunctions; -``` - -Defined in: [packages/db/src/indexes/base-index.ts:11](https://github.com/TanStack/db/blob/main/packages/db/src/indexes/base-index.ts#L11) - -Operations that indexes can support, imported from available comparison functions diff --git a/docs/reference/variables/Query.md b/docs/reference/variables/Query.md index 258d4053a..30e7d7ba3 100644 --- a/docs/reference/variables/Query.md +++ b/docs/reference/variables/Query.md @@ -9,4 +9,4 @@ title: Query const Query: InitialQueryBuilderConstructor = BaseQueryBuilder; ``` -Defined in: [packages/db/src/query/builder/index.ts:912](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L912) +Defined in: [packages/db/src/query/builder/index.ts:1232](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/index.ts#L1232) diff --git a/docs/reference/variables/operators.md b/docs/reference/variables/operators.md index 1d6471cc9..ba035e48e 100644 --- a/docs/reference/variables/operators.md +++ b/docs/reference/variables/operators.md @@ -9,6 +9,6 @@ title: operators const operators: readonly ["eq", "gt", "gte", "lt", "lte", "in", "like", "ilike", "and", "or", "not", "isNull", "isUndefined", "upper", "lower", "length", "concat", "add", "coalesce", "count", "avg", "sum", "min", "max"]; ``` -Defined in: [packages/db/src/query/builder/functions.ts:344](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L344) +Defined in: [packages/db/src/query/builder/functions.ts:403](https://github.com/TanStack/db/blob/main/packages/db/src/query/builder/functions.ts#L403) All supported operator names in TanStack DB expressions