@@ -7,7 +7,7 @@ title: QueryCollectionConfig
7
7
8
8
# Interface: QueryCollectionConfig\< TItem, TError, TQueryKey\>
9
9
10
- Defined in: [ packages/query-db-collection/src/query.ts:26 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L26 )
10
+ Defined in: [ packages/query-db-collection/src/query.ts:32 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L32 )
11
11
12
12
## Type Parameters
13
13
@@ -25,7 +25,7 @@ Defined in: [packages/query-db-collection/src/query.ts:26](https://github.com/Ta
25
25
optional enabled : boolean ;
26
26
```
27
27
28
- Defined in: [ packages/query-db-collection/src/query.ts:36 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L36 )
28
+ Defined in: [ packages/query-db-collection/src/query.ts:42 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L42 )
29
29
30
30
***
31
31
@@ -35,7 +35,7 @@ Defined in: [packages/query-db-collection/src/query.ts:36](https://github.com/Ta
35
35
getKey : (item ) => string | number ;
36
36
```
37
37
38
- Defined in: [ packages/query-db-collection/src/query.ts:68 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L68 )
38
+ 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 )
39
39
40
40
#### Parameters
41
41
@@ -55,7 +55,39 @@ Defined in: [packages/query-db-collection/src/query.ts:68](https://github.com/Ta
55
55
optional id : string ;
56
56
```
57
57
58
- Defined in: [ packages/query-db-collection/src/query.ts:67] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L67 )
58
+ 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 )
59
+
60
+ ***
61
+
62
+ ### meta?
63
+
64
+ ``` ts
65
+ optional meta : Record < string , unknown > ;
66
+ ```
67
+
68
+ Defined in: [ packages/query-db-collection/src/query.ts:242] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L242 )
69
+
70
+ Metadata to pass to the query.
71
+ Available in queryFn via context.meta
72
+
73
+ #### Example
74
+
75
+ ``` ts
76
+ // Using meta for error context
77
+ queryFn : async (context ) => {
78
+ try {
79
+ return await api .getTodos (userId )
80
+ } catch (error ) {
81
+ // Use meta for better error messages
82
+ throw new Error (
83
+ context .meta ?.errorMessage || ' Failed to load todos'
84
+ )
85
+ }
86
+ },
87
+ meta : {
88
+ errorMessage : ` Failed to load todos for user ${userId } `
89
+ }
90
+ ```
59
91
60
92
***
61
93
@@ -65,7 +97,7 @@ Defined in: [packages/query-db-collection/src/query.ts:67](https://github.com/Ta
65
97
optional onDelete : DeleteMutationFn < TItem > ;
66
98
```
67
99
68
- Defined in: [ packages/query-db-collection/src/query.ts:213 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L213 )
100
+ Defined in: [ packages/query-db-collection/src/query.ts:219 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L219 )
69
101
70
102
Optional asynchronous handler function called before a delete operation
71
103
@@ -131,7 +163,7 @@ onDelete: async ({ transaction, collection }) => {
131
163
optional onInsert : InsertMutationFn < TItem > ;
132
164
```
133
165
134
- 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 )
166
+ Defined in: [ packages/query-db-collection/src/query.ts:120 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L120 )
135
167
136
168
Optional asynchronous handler function called before an insert operation
137
169
@@ -193,7 +225,7 @@ onInsert: async ({ transaction }) => {
193
225
optional onUpdate : UpdateMutationFn < TItem > ;
194
226
```
195
227
196
- Defined in: [ packages/query-db-collection/src/query.ts:167 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L167 )
228
+ Defined in: [ packages/query-db-collection/src/query.ts:173 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L173 )
197
229
198
230
Optional asynchronous handler function called before an update operation
199
231
@@ -266,7 +298,7 @@ onUpdate: async ({ transaction, collection }) => {
266
298
queryClient : QueryClient ;
267
299
```
268
300
269
- Defined in: [ packages/query-db-collection/src/query.ts:33 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L33 )
301
+ Defined in: [ packages/query-db-collection/src/query.ts:39 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L39 )
270
302
271
303
***
272
304
@@ -276,7 +308,7 @@ Defined in: [packages/query-db-collection/src/query.ts:33](https://github.com/Ta
276
308
queryFn : (context ) => Promise < TItem []> ;
277
309
```
278
310
279
- Defined in: [ packages/query-db-collection/src/query.ts:32 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L32 )
311
+ Defined in: [ packages/query-db-collection/src/query.ts:38 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L38 )
280
312
281
313
#### Parameters
282
314
@@ -322,7 +354,7 @@ if you want access to the direction, you can add it to the pageParam
322
354
queryKey : TQueryKey ;
323
355
```
324
356
325
- Defined in: [ packages/query-db-collection/src/query.ts:31 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L31 )
357
+ Defined in: [ packages/query-db-collection/src/query.ts:37 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L37 )
326
358
327
359
***
328
360
@@ -332,7 +364,7 @@ Defined in: [packages/query-db-collection/src/query.ts:31](https://github.com/Ta
332
364
optional refetchInterval : number | false | (query ) => undefined | number | false ;
333
365
```
334
366
335
- Defined in: [ packages/query-db-collection/src/query.ts:37 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L37 )
367
+ Defined in: [ packages/query-db-collection/src/query.ts:43 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L43 )
336
368
337
369
***
338
370
@@ -342,7 +374,7 @@ Defined in: [packages/query-db-collection/src/query.ts:37](https://github.com/Ta
342
374
optional retry : RetryValue < TError > ;
343
375
```
344
376
345
- Defined in: [ packages/query-db-collection/src/query.ts:44 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L44 )
377
+ Defined in: [ packages/query-db-collection/src/query.ts:50 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L50 )
346
378
347
379
***
348
380
@@ -352,7 +384,7 @@ Defined in: [packages/query-db-collection/src/query.ts:44](https://github.com/Ta
352
384
optional retryDelay : RetryDelayValue < TError > ;
353
385
```
354
386
355
- Defined in: [ packages/query-db-collection/src/query.ts:51 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L51 )
387
+ Defined in: [ packages/query-db-collection/src/query.ts:57 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L57 )
356
388
357
389
***
358
390
@@ -362,17 +394,17 @@ Defined in: [packages/query-db-collection/src/query.ts:51](https://github.com/Ta
362
394
optional schema : StandardSchemaV1 < unknown , unknown > ;
363
395
```
364
396
365
- Defined in: [ packages/query-db-collection/src/query.ts:69 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L69 )
397
+ 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 )
366
398
367
399
***
368
400
369
401
### staleTime?
370
402
371
403
``` ts
372
- optional staleTime : StaleTime < TItem [], TError , TItem [], TQueryKey > ;
404
+ optional staleTime : StaleTimeFunction < TItem [], TError , TItem [], TQueryKey > ;
373
405
```
374
406
375
- Defined in: [ packages/query-db-collection/src/query.ts:58 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L58 )
407
+ Defined in: [ packages/query-db-collection/src/query.ts:64 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L64 )
376
408
377
409
***
378
410
@@ -382,7 +414,7 @@ Defined in: [packages/query-db-collection/src/query.ts:58](https://github.com/Ta
382
414
optional startSync : boolean ;
383
415
```
384
416
385
- Defined in: [ packages/query-db-collection/src/query.ts:71 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L71 )
417
+ Defined in: [ packages/query-db-collection/src/query.ts:77 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L77 )
386
418
387
419
***
388
420
@@ -392,4 +424,4 @@ Defined in: [packages/query-db-collection/src/query.ts:71](https://github.com/Ta
392
424
optional sync : SyncConfig < TItem , string | number > ;
393
425
```
394
426
395
- Defined in: [ packages/query-db-collection/src/query.ts:70 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L70 )
427
+ Defined in: [ packages/query-db-collection/src/query.ts:76 ] ( https://github.com/TanStack/db/blob/main/packages/query-db-collection/src/query.ts#L76 )
0 commit comments