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

CreateOptimisticActionsOptions.md

122 lines2.0 KB

1---
2id: CreateOptimisticActionsOptions
3title: CreateOptimisticActionsOptions
4---
5​
6# Interface: CreateOptimisticActionsOptions\<TVars, T\>
7​
8Defined in: [packages/db/src/types.ts:159](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L159)
9​
10Options for the createOptimisticAction helper
11​
12## Extends
13​
14- `Omit`\<[`TransactionConfig`](../TransactionConfig.md)\<`T`\>, `"mutationFn"`\>
15​
16## Type Parameters
17​
18### TVars
19​
20`TVars` = `unknown`
21​
22### T
23​
24`T` *extends* `object` = `Record`\<`string`, `unknown`\>
25​
26## Properties
27​
28### autoCommit?
29​
30```ts
31optional autoCommit: boolean;
32```
33​
34Defined in: [packages/db/src/types.ts:150](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L150)
35​
36#### Inherited from
37​
38[`TransactionConfig`](../TransactionConfig.md).[`autoCommit`](../TransactionConfig.md#autocommit)
39​
40***
41​
42### id?
43​
44```ts
45optional id: string;
46```
47​
48Defined in: [packages/db/src/types.ts:148](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L148)
49​
50Unique identifier for the transaction
51​
52#### Inherited from
53​
54```ts
55Omit.id
56```
57​
58***
59​
60### metadata?
61​
62```ts
63optional metadata: Record<string, unknown>;
64```
65​
66Defined in: [packages/db/src/types.ts:153](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L153)
67​
68Custom metadata to associate with the transaction
69​
70#### Inherited from
71​
72```ts
73Omit.metadata
74```
75​
76***
77​
78### mutationFn()
79​
80```ts
81mutationFn: (vars, params) => Promise<any>;
82```
83​
84Defined in: [packages/db/src/types.ts:166](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L166)
85​
86Function to execute the mutation on the server
87​
88#### Parameters
89​
90##### vars
91​
92`TVars`
93​
94##### params
95​
96[`MutationFnParams`](../../type-aliases/MutationFnParams.md)\<`T`\>
97​
98#### Returns
99​
100`Promise`\<`any`\>
101​
102***
103​
104### onMutate()
105​
106```ts
107onMutate: (vars) => void;
108```
109​
110Defined in: [packages/db/src/types.ts:164](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L164)
111​
112Function to apply optimistic updates locally before the mutation completes
113​
114#### Parameters
115​
116##### vars
117​
118`TVars`
119​
120#### Returns
121​
122`void`