Open History to see the last commit
1---
2id: SyncConfig
3title: SyncConfig
4---
5
6Defined in: [packages/db/src/types.ts:445](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L445)
7
8## Type Parameters
9
10### T
11
12`T` *extends* `object` = `Record`\<`string`, `unknown`\>
13
14### TKey
15
16`TKey` *extends* `string` \| `number` = `string` \| `number`
17
18## Properties
19
20### exportSyncMeta()?
21
22```ts
23optional exportSyncMeta: () => unknown;
24```
25
26Defined in: [packages/db/src/types.ts:520](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L520)
27
28Export adapter-specific metadata that lets hydration/persistence resume sync.
29The payload shape is owned by the adapter.
30
31#### Returns
32
33`unknown`
34
35***
36
37### getSyncMetadata()?
38
39```ts
40optional getSyncMetadata: () => Record<string, unknown>;
41```
42
43Defined in: [packages/db/src/types.ts:514](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L514)
44
45Get the sync metadata for insert operations
46
47#### Returns
48
49`Record`\<`string`, `unknown`\>
50
51Record containing relation information
52
53***
54
55### importSyncMeta()?
56
57```ts
58optional importSyncMeta: (meta) => void;
59```
60
61Defined in: [packages/db/src/types.ts:525](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L525)
62
63Import adapter-specific metadata produced by exportSyncMeta.
64
65#### Parameters
66
67##### meta
68
69`unknown`
70
71#### Returns
72
73`void`
74
75***
76
77### mergeSyncMeta()?
78
79```ts
80optional mergeSyncMeta: (current, incoming) => unknown;
81```
82
83Defined in: [packages/db/src/types.ts:530](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L530)
84
85Merge two adapter-specific metadata payloads during hydration.
86
87#### Parameters
88
89##### current
90
91`unknown`
92
93##### incoming
94
95`unknown`
96
97#### Returns
98
99`unknown`
100
101***
102
103### rowUpdateMode?
104
105```ts
106optional rowUpdateMode: "full" | "partial";
107```
108
109Defined in: [packages/db/src/types.ts:539](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L539)
110
111The row update mode used to sync to the collection.
112
113#### Default
114
115`partial`
116
117#### Description
118
119- `partial`: Updates contain only the changes to the row.
120- `full`: Updates contain the entire row.
121
122***
123
124### sync()
125
126```ts
127sync: (params) =>
128 | void
129 | CleanupFn
130 | SyncConfigRes;
131```
132
133Defined in: [packages/db/src/types.ts:449](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L449)
134
135#### Parameters
136
137##### params
138
139###### begin
140
141(`options?`) => `void`
142
143Begin a new sync transaction. `direct: true` marks a direct write: an
144edit of the rows on screen, not part of the sync run's snapshot. During
145a reload it applies to the kept rows, and the reload's replacement of
146every row waits for the run's next transaction.
147
148###### collection
149
150[`Collection`](Collection.md)\<`T`, `TKey`, `any`, `any`, `any`\>
151
152###### commit
153
154(`signal?`) => [`SyncAppliedReceipt`](../type-aliases/SyncAppliedReceipt.md)
155
156Commit the active sync transaction in FIFO order. Core accepts it at
157once, and an accepted transaction always applies. Returns `true` when
158its writes are visible, or a receipt that resolves when they become
159visible. While an optimistic transaction is persisting, it becomes
160visible when that transaction settles, together with the drop of its
161optimistic state. A signal that is already aborted abandons the
162transaction before acceptance, and the receipt rejects with an error
163named `AbortError`. Aborting after acceptance has no effect.
164
165###### fail
166
167(`error`) => `void`
168
169The sync adapter stopped. Before the first ready the status becomes
170`error` and `preload()` rejects with `error`. After it, the rows stay, the
171status stays `ready`, and the node's `error` holds the cause until a
172reload. A second `fail()` in the same sync run does nothing.
173While the sync adapter retries, call nothing or `reportError()`.
174
175###### invalidateLoadedSubsets
176
177() => `void`
178
179Report that rows this adapter serves for loaded subsets may have shifted
180between served pages, after a refetch that the adapter started on its
181own has applied. Each ordered live query then re-establishes its window
182with a bounded repair from the start of its order. Calls in one turn are
183coalesced. Do not call it for results that answer a `loadSubset` call.
184
185###### markReady
186
187() => `void`
188
189Signal that a usable initial snapshot is available for this attempt.
190
191###### metadata?
192
193[`SyncMetadataApi`](SyncMetadataApi.md)\<`TKey`\>
194
195###### reportError
196
197(`error`) => `void`
198
199Report a problem after the first ready while the sync adapter keeps
200trying. It shows as the node's `failureReason`; the status and rows do
201not change. Throws before the first ready and after `fail()`.
202
203###### reportHealthy
204
205() => `void`
206
207Sync works again: clears a `failureReason`. With nothing to clear it does
208nothing, so it can follow every commit. Throws before the first ready
209and after `fail()`.
210
211###### truncate
212
213(`options?`) => `void`
214
215Replace the synced rows. By default the replacement also marks the
216Collection ready. Set markReady:false to publish without changing status,
217for example when confirming a committed write from a closed source.
218The last truncate in a transaction supplies its readiness intent.
219
220###### write
221
222(`message`) => `void`
223
224#### Returns
225
226 \| `void`
227 \| [`CleanupFn`](../type-aliases/CleanupFn.md)
228 \| [`SyncConfigRes`](../type-aliases/SyncConfigRes.md)