Open History to see the last commit
1---
2id: LocalOnlyCollectionConfig
3title: LocalOnlyCollectionConfig
4---
5
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7
8# Interface: LocalOnlyCollectionConfig\<TExplicit, TSchema, TFallback, TKey\>
9
10Defined in: [packages/db/src/local-only.ts:27](https://github.com/TanStack/db/blob/main/packages/db/src/local-only.ts#L27)
11
12Configuration interface for Local-only collection options
13
14## Remarks
15
16Type resolution follows a priority order:
171. If you provide an explicit type via generic parameter, it will be used
182. If no explicit type is provided but a schema is, the schema's output type will be inferred
193. If neither explicit type nor schema is provided, the fallback type will be used
20
21You should provide EITHER an explicit type OR a schema, but not both, as they would conflict.
22
23## Type Parameters
24
25• **TExplicit** = `unknown`
26
27The explicit type of items in the collection (highest priority)
28
29• **TSchema** *extends* `StandardSchemaV1` = `never`
30
31The schema type for validation and type inference (second priority)
32
33• **TFallback** *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
34
35The fallback type if no explicit or schema type is provided
36
37• **TKey** *extends* `string` \| `number` = `string` \| `number`
38
39The type of the key returned by getKey
40
41## Properties
42
43### getKey()
44
45```ts
46getKey: (item) => TKey;
47```
48
49Defined in: [packages/db/src/local-only.ts:38](https://github.com/TanStack/db/blob/main/packages/db/src/local-only.ts#L38)
50
51#### Parameters
52
53##### item
54
55[`ResolveType`](../../type-aliases/resolvetype.md)\<`TExplicit`, `TSchema`, `TFallback`\>
56
57#### Returns
58
59`TKey`
60
61***
62
63### id?
64
65```ts
66optional id: string;
67```
68
69Defined in: [packages/db/src/local-only.ts:36](https://github.com/TanStack/db/blob/main/packages/db/src/local-only.ts#L36)
70
71Standard Collection configuration properties
72
73***
74
75### initialData?
76
77```ts
78optional initialData: ResolveType<TExplicit, TSchema, TFallback>[];
79```
80
81Defined in: [packages/db/src/local-only.ts:44](https://github.com/TanStack/db/blob/main/packages/db/src/local-only.ts#L44)
82
83Optional initial data to populate the collection with on creation
84This data will be applied during the initial sync process
85
86***
87
88### onDelete()?
89
90```ts
91optional onDelete: (params) => Promise<any>;
92```
93
94Defined in: [packages/db/src/local-only.ts:77](https://github.com/TanStack/db/blob/main/packages/db/src/local-only.ts#L77)
95
96Optional asynchronous handler function called after a delete operation
97
98#### Parameters
99
100##### params
101
102[`DeleteMutationFnParams`](../../type-aliases/deletemutationfnparams.md)\<[`ResolveType`](../../type-aliases/resolvetype.md)\<`TExplicit`, `TSchema`, `TFallback`\>, `TKey`, [`LocalOnlyCollectionUtils`](../localonlycollectionutils.md)\>
103
104Object containing transaction and collection information
105
106#### Returns
107
108`Promise`\<`any`\>
109
110Promise resolving to any value
111
112***
113
114### onInsert()?
115
116```ts
117optional onInsert: (params) => Promise<any>;
118```
119
120Defined in: [packages/db/src/local-only.ts:51](https://github.com/TanStack/db/blob/main/packages/db/src/local-only.ts#L51)
121
122Optional asynchronous handler function called after an insert operation
123
124#### Parameters
125
126##### params
127
128[`InsertMutationFnParams`](../../type-aliases/insertmutationfnparams.md)\<[`ResolveType`](../../type-aliases/resolvetype.md)\<`TExplicit`, `TSchema`, `TFallback`\>, `TKey`, [`LocalOnlyCollectionUtils`](../localonlycollectionutils.md)\>
129
130Object containing transaction and collection information
131
132#### Returns
133
134`Promise`\<`any`\>
135
136Promise resolving to any value
137
138***
139
140### onUpdate()?
141
142```ts
143optional onUpdate: (params) => Promise<any>;
144```
145
146Defined in: [packages/db/src/local-only.ts:64](https://github.com/TanStack/db/blob/main/packages/db/src/local-only.ts#L64)
147
148Optional asynchronous handler function called after an update operation
149
150#### Parameters
151
152##### params
153
154[`UpdateMutationFnParams`](../../type-aliases/updatemutationfnparams.md)\<[`ResolveType`](../../type-aliases/resolvetype.md)\<`TExplicit`, `TSchema`, `TFallback`\>, `TKey`, [`LocalOnlyCollectionUtils`](../localonlycollectionutils.md)\>
155
156Object containing transaction and collection information
157
158#### Returns
159
160`Promise`\<`any`\>
161
162Promise resolving to any value
163
164***
165
166### schema?
167
168```ts
169optional schema: TSchema;
170```
171
172Defined in: [packages/db/src/local-only.ts:37](https://github.com/TanStack/db/blob/main/packages/db/src/local-only.ts#L37)