File: QueryCollectionConfig.md | Updated: 11/15/2025
Search...
+ K
Auto
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide
Documentation
Framework
React
Version
Latest
Search...
+ K
Menu
Getting Started
Guides
Collections
Frameworks
Community
API Reference
Framework
React
Version
Latest
Menu
Getting Started
Guides
Collections
Frameworks
Community
API Reference
On this page
Copy Markdown
Defined in: packages/query-db-collection/src/query.ts:59
Configuration options for creating a Query Collection
Type Parameters
---------------
### T
T extends object = object
The explicit type of items stored in the collection
TQueryFn extends (context) => Promise<any> = (context) => Promise<any>
The queryFn type
TError = unknown
The type of errors that can occur during queries
TQueryKey extends QueryKey = QueryKey
The type of the query key
TKey extends string | number = string | number
The type of the item keys
TSchema extends StandardSchemaV1 = never
The schema type for validation
TQueryData = Awaited<ReturnType<TQueryFn>>
Properties
----------
### enabled?
ts
optional enabled: boolean;
optional enabled: boolean;
Defined in: packages/query-db-collection/src/query.ts:85
Whether the query should automatically run (default: true)
ts
optional meta: Record<string, unknown>;
optional meta: Record<string, unknown>;
Defined in: packages/query-db-collection/src/query.ts:135
Metadata to pass to the query. Available in queryFn via context.meta
ts
// Using meta for error context
queryFn: async (context) => {
try {
return await api.getTodos(userId)
} catch (error) {
// Use meta for better error messages
throw new Error(
context.meta?.errorMessage || 'Failed to load todos'
)
}
},
meta: {
errorMessage: `Failed to load todos for user ${userId}`
}
// Using meta for error context
queryFn: async (context) => {
try {
return await api.getTodos(userId)
} catch (error) {
// Use meta for better error messages
throw new Error(
context.meta?.errorMessage || 'Failed to load todos'
)
}
},
meta: {
errorMessage: `Failed to load todos for user ${userId}`
}
ts
queryClient: QueryClient;
queryClient: QueryClient;
Defined in: packages/query-db-collection/src/query.ts:81
The TanStack Query client instance
ts
queryFn: TQueryFn extends (context) => Promise<any[]> ? (context) => Promise<T[]> : TQueryFn;
queryFn: TQueryFn extends (context) => Promise<any[]> ? (context) => Promise<T[]> : TQueryFn;
Defined in: packages/query-db-collection/src/query.ts:73
Function that fetches data from the server. Must return the complete collection state
ts
queryKey: TQueryKey | TQueryKeyBuilder<TQueryKey>;
queryKey: TQueryKey | TQueryKeyBuilder<TQueryKey>;
Defined in: packages/query-db-collection/src/query.ts:71
The query key used by TanStack Query to identify this query
ts
optional refetchInterval: number | false | (query) => number | false | undefined;
optional refetchInterval: number | false | (query) => number | false | undefined;
Defined in: packages/query-db-collection/src/query.ts:86
ts
optional retry: RetryValue<TError>;
optional retry: RetryValue<TError>;
Defined in: packages/query-db-collection/src/query.ts:93
ts
optional retryDelay: RetryDelayValue<TError>;
optional retryDelay: RetryDelayValue<TError>;
Defined in: packages/query-db-collection/src/query.ts:100
ts
optional select: (data) => T[];
optional select: (data) => T[];
Defined in: packages/query-db-collection/src/query.ts:79
TQueryData
T[]
ts
optional staleTime: StaleTimeFunction<T[], TError, T[], TQueryKey>;
optional staleTime: StaleTimeFunction<T[], TError, T[], TQueryKey>;
Defined in: packages/query-db-collection/src/query.ts:107
