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<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8# Interface: CreateOptimisticActionsOptions\<TVars, T\>
9​
10Defined in: [packages/db/src/types.ts:174](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L174)
11​
12Options for the createOptimisticAction helper
13​
14## Extends
15​
16- `Omit`\<[`TransactionConfig`](../transactionconfig.md)\<`T`\>, `"mutationFn"`\>
17​
18## Type Parameters
19​
20• **TVars** = `unknown`
21​
22• **T** *extends* `object` = `Record`\<`string`, `unknown`\>
23​
24## Properties
25​
26### autoCommit?
27​
28```ts
29optional autoCommit: boolean;
30```
31​
32Defined in: [packages/db/src/types.ts:165](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L165)
33​
34#### Inherited from
35​
36```ts
37Omit.autoCommit
38```
39​
40***
41​
42### id?
43​
44```ts
45optional id: string;
46```
47​
48Defined in: [packages/db/src/types.ts:163](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L163)
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:168](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L168)
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:181](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L181)
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:179](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L179)
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`