Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

SyncConfig.md

192 lines3.5 KB

1---
2id: SyncConfig
3title: SyncConfig
4---
5​
6# Interface: SyncConfig\<T, TKey\>
7​
8Defined in: [packages/db/src/types.ts:365](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L365)
9​
10## Type Parameters
11​
12### T
13​
14`T` *extends* `object` = `Record`\<`string`, `unknown`\>
15​
16### TKey
17​
18`TKey` *extends* `string` \| `number` = `string` \| `number`
19​
20## Properties
21​
22### exportSyncMeta()?
23​
24```ts
25optional exportSyncMeta: () => unknown;
26```
27​
28Defined in: [packages/db/src/types.ts:409](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L409)
29​
30Export adapter-specific metadata that lets hydration/persistence resume sync.
31The payload shape is owned by the adapter.
32​
33#### Returns
34​
35`unknown`
36​
37***
38​
39### getSyncMetadata()?
40​
41```ts
42optional getSyncMetadata: () => Record<string, unknown>;
43```
44​
45Defined in: [packages/db/src/types.ts:403](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L403)
46​
47Get the sync metadata for insert operations
48​
49#### Returns
50​
51`Record`\<`string`, `unknown`\>
52​
53Record containing relation information
54​
55***
56​
57### importSyncMeta()?
58​
59```ts
60optional importSyncMeta: (meta) => void;
61```
62​
63Defined in: [packages/db/src/types.ts:414](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L414)
64​
65Import adapter-specific metadata produced by exportSyncMeta.
66​
67#### Parameters
68​
69##### meta
70​
71`unknown`
72​
73#### Returns
74​
75`void`
76​
77***
78​
79### mergeSyncMeta()?
80​
81```ts
82optional mergeSyncMeta: (current, incoming) => unknown;
83```
84​
85Defined in: [packages/db/src/types.ts:419](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L419)
86​
87Merge two adapter-specific metadata payloads during hydration.
88​
89#### Parameters
90​
91##### current
92​
93`unknown`
94​
95##### incoming
96​
97`unknown`
98​
99#### Returns
100​
101`unknown`
102​
103***
104​
105### rowUpdateMode?
106​
107```ts
108optional rowUpdateMode: "full" | "partial";
109```
110​
111Defined in: [packages/db/src/types.ts:428](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L428)
112​
113The row update mode used to sync to the collection.
114​
115#### Default
116​
117`partial`
118​
119#### Description
120​
121- `partial`: Updates contain only the changes to the row.
122- `full`: Updates contain the entire row.
123​
124***
125​
126### sync()
127​
128```ts
129sync: (params) =>
130 | void
131 | CleanupFn
132 | SyncConfigRes;
133```
134​
135Defined in: [packages/db/src/types.ts:369](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L369)
136​
137#### Parameters
138​
139##### params
140​
141###### begin
142​
143(`options?`) => `void`
144​
145Begin a new sync transaction.
146​
147###### collection
148​
149[`Collection`](Collection.md)\<`T`, `TKey`, `any`, `any`, `any`\>
150​
151###### commit
152​
153(`signal?`) => [`SyncAppliedReceipt`](../type-aliases/SyncAppliedReceipt.md)
154​
155Commit the active sync transaction in FIFO order.
156Returns `true` when the writes and events are already visible. Otherwise
157returns a receipt that resolves after they become visible. If collection
158cleanup or an optional request abort abandons the transaction first, the
159receipt rejects with an error named `AbortError`.
160Pass a signal only for request-scoped work that must not publish after
161cancellation. Aborting after application has no effect.
162​
163###### markError
164​
165(`error?`) => `void`
166​
167Signal that initial sync failed before producing a usable snapshot.
168When supplied, `error` is preserved as the rejection reason from `preload()`.
169​
170###### markReady
171​
172() => `void`
173​
174Signal that a usable initial or recovered snapshot is available.
175​
176###### metadata?
177​
178[`SyncMetadataApi`](SyncMetadataApi.md)\<`TKey`\>
179​
180###### truncate
181​
182() => `void`
183​
184###### write
185​
186(`message`) => `void`
187​
188#### Returns
189​
190 \| `void`
191 \| [`CleanupFn`](../type-aliases/CleanupFn.md)
192 \| [`SyncConfigRes`](../type-aliases/SyncConfigRes.md)