> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Interface: OptimisticLocalStore

> A view of the query results currently in the Bijection client for use within optimistic updates.

[browser](/api/modules/browser).OptimisticLocalStore

A view of the query results currently in the Bijection client for use within
optimistic updates.

## Methods

### getQuery

▸ **getQuery**\<`Query`>(`query`, `...args`): `undefined` | [`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Query`>

Retrieve the result of a query from the client.

Important: Query results should be treated as immutable!
Always make new copies of structures within query results to avoid
corrupting data within the client.

#### Type parameters

| Name | Type |
| :- | :- |
| `Query` | extends [`FunctionReference`](/api/modules/server#functionreference)\<`"query"`> \| [`FunctionReference_future`](/api/modules/server#functionreference_future)\<`"query"`> |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `query` | `Query` | A [FunctionReference](/api/modules/server#functionreference) for the query to get. |
| `...args` | [`OptionalRestArgs`](/api/modules/server#optionalrestargs)\<`Query`> | The arguments object for this query. |

#### Returns

`undefined` | [`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Query`>

The query result or `undefined` if the query is not currently
in the client.

***

### getAllQueries

▸ **getAllQueries**\<`Query`>(`query`): \{ `args`: [`FunctionArgs`](/api/modules/server#functionargs)\<`Query`> ; `value`: `undefined` | [`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Query`>  }\[]

Retrieve the results and arguments of all queries with a given name.

This is useful for complex optimistic updates that need to inspect and
update many query results (for example updating a paginated list).

Important: Query results should be treated as immutable!
Always make new copies of structures within query results to avoid
corrupting data within the client.

#### Type parameters

| Name | Type |
| :- | :- |
| `Query` | extends [`FunctionReference`](/api/modules/server#functionreference)\<`"query"`> \| [`FunctionReference_future`](/api/modules/server#functionreference_future)\<`"query"`> |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `query` | `Query` | A [FunctionReference](/api/modules/server#functionreference) for the query to get. |

#### Returns

\{ `args`: [`FunctionArgs`](/api/modules/server#functionargs)\<`Query`> ; `value`: `undefined` | [`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Query`>  }\[]

An array of objects, one for each query of the given name.
Each object includes:

* `args` - The arguments object for the query.
* `value` The query result or `undefined` if the query is loading.

***

### setQuery

▸ **setQuery**\<`Query`>(`query`, `args`, `value`): `void`

Optimistically update the result of a query.

This can either be a new value (perhaps derived from the old value from
[getQuery](/api/interfaces/browser.OptimisticLocalStore#getquery)) or `undefined` to remove the query.
Removing a query is useful to create loading states while Bijection recomputes
the query results.

#### Type parameters

| Name | Type |
| :- | :- |
| `Query` | extends [`FunctionReference`](/api/modules/server#functionreference)\<`"query"`> \| [`FunctionReference_future`](/api/modules/server#functionreference_future)\<`"query"`> |

#### Parameters

| Name | Type | Description |
| :- | :- | :- |
| `query` | `Query` | A [FunctionReference](/api/modules/server#functionreference) for the query to set. |
| `args` | [`FunctionArgs`](/api/modules/server#functionargs)\<`Query`> | The arguments object for this query. |
| `value` | `undefined` \| [`FunctionReturnType`](/api/modules/server#functionreturntype)\<`Query`> | The new value to set the query to or `undefined` to remove it from the client. |

#### Returns

`void`
