# ComputedQuery

**Category:** Common/Types

## API

### Overview

`ComputedQuery` represents the current paging, sorting, and filtering state passed to `fetchData`. It includes `offset` (or `cursor`), `limit`, `sort`, and `filter` values derived from the active filters. Use it in bulk operations like `updateAll` or `deleteAll` to apply the same filters server-side.

### Description

The argument passed to the `fetchData()` function.

The `fetchData()` function is responsible for fetching data collections and is defined within collection hooks like [`useTableCollection()`](./?path=/story/base-components-collections-table-usetablecollection--usetablecollection) and [`useGridCollection()`](./?path=/story/base-components-collections-grid-usegridcollection--usegridcollection).

`ComputedQuery` ensures that queries align with the expected input of the server. It supports both `offset` and `cursor` pagination modes, which can be set by adjusting the `paginationMode` property in the relevant hook.

For type support, you can optionally import `OffsetQuery` or `CursorQuery`.

```tsx
import { OffsetQuery } from '@wix/patterns';
import { CursorQuery } from '@wix/patterns';
```

---

### Props

| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `limit` | `number` | Yes | - | Number of items to fetch for each page |
| `offset` | `number` | Yes | - | The index of the item to start fetching items from.<br> Relevant for APIs that support offset pagination.<br> Not available on `CursorQuery`. |
| `search` | `string` | No | - | Current search term. Defaults to `undefined` for empty search. |
| `rawSearch` | `string` | Yes | - | Current search term. Defaults to `''` for empty search. |
| `cursor` | `string \| null` | No | - | The `cursor` returned from the server, to be sent back to it in the next call.<br> Relevant for APIs that support cursor pagination.<br> Not available on `OffsetQuery`. |
| `filters` | `Partial<{ [P in keyof F]: ExtractFilterValue<F[P]>; }>` | Yes | - | Current state of the filters. Each key holds the value of the filter, according to its type, defined in [CollectionConfig](./?path=/story/common-hooks--usecollection). |
| `rawFilters` | `Partial<{ [P in keyof F]: ExtractFilterValue<F[P]>; }>` | Yes | - | Same as `filters` but defaults to `undefined` for empty filter values. |
| `hasActiveFilters` | `boolean` | Yes | - | Whether at least one filter is not empty. |
| `hasNonPersistentActiveFilters` | `boolean` | Yes | - | Whether at least one filter is not empty, not including tabs. |
| `sort` | `{ fieldName: string; order: "asc" \| "desc"; }[]` | No | - | Current sort applied to the collection. |
| `columns` | `string[]` | No | - | @deprecated Use `fields` instead |
| `fields` | `string[]` | No | - | Array of projected fields. A list of specific field names to fetch. Use this to optimize your server query to load only needed columns. Note that a mapping between client-side columns to server-fields is usually required. Use `refreshOnColumnsChange` of [useCollection](./?path=/story/common-hooks--usecollection) to control whether the collection should be refreshed when this value changes. |
| `extra` | `string` | No | - | Extra data to be passed to the query. |

