> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: About Query Builder Utilities

## Article: About Query Builder Utilities

## Article Link: https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-query-builder-utilities.md

## Article Content:

# About Query Builder Utilities

The Wix JavaScript SDK provides query builder utility methods that let you construct query requests using a chainable syntax. You can pass the resulting query object directly to any SDK query method.

## Why use query builder utilities

SDK query methods accept queries written in the [Wix API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md), a JSON-based format for filtering, sorting, and paging. While this format is flexible and consistent across all Wix APIs, building these objects can be difficult, especially for complex queries.

Query builder utilities offer the following benefits:

- **Chainable syntax.** Construct queries by chaining method calls such as `.withFilter()` and `.withSorting()`, rather than writing JSON objects by hand.
- **Programmatic composition.** Build filter and sort conditions dynamically based on runtime logic, then combine them into a single query.
- **Type safety.** The utility methods are fully typed, providing autocompletion and compile-time checks in TypeScript projects.

## Available utilities

Each SDK API exports the following utilities alongside its query methods:

| Utility | Purpose |
|---------|---------|
| `Filter(fieldName)` | Creates a filter condition for a specified field. Supports operators like `.eq()`, `.ne()`, `.gt()`, `.gte()`, `.lt()`, `.lte()`, `.in()`, `.nin()`, `.exists()`, `.startsWith()`, `.isEmpty()`, `.hasAll()`, and `.hasSome()`. |
| `Sort(fieldName)` | Creates a sort condition for a specified field. Supports `.asc()` for ascending and `.desc()` for descending order. |
| `QueryBuilder()` | Combines filters, sorts, and paging into a complete query object. Supports `.withFilter()`, `.withSorting()`, `.withPaging()`, and `.build()`. |

## Code examples

The following examples query bookings services for all services of type `"COURSE"`, sorted by `name` in ascending order.

### With query builder utilities

```javascript
import { services } from '@wix/bookings';

const { QueryBuilder, Filter, Sort } = services.utils.query;

const query = QueryBuilder()
  .withFilter(Filter('type').eq('COURSE'))
  .withSorting(Sort('name').asc())
  .withPaging({ limit: 10, offset: 0 })
  .build();

const response = await services.queryServices(query);
```

### With a direct query object

```javascript
import { services } from '@wix/bookings';

const response = await services.queryServices({
  filter: {
    type: {
      $eq: 'COURSE'
    }
  },
  sort: [
    {
      fieldName: 'name',
      order: 'ASC'
    }
  ],
  paging: {
      limit: 10,
      offset: 0
  }
});
```

## Building dynamic queries

Query builder utilities are particularly useful when you need to construct queries based on conditions that aren't known until runtime. Instead of manually assembling a JSON filter object, you can compose filters and sorts programmatically.

For example, the following helper method builds a query for Bookings services where the filter and sort are optional and determined by the caller:

```javascript
import { services } from '@wix/bookings';

const { QueryBuilder, Filter, Sort } = services.utils.query;

function buildServiceQuery(options) {
  let builder = QueryBuilder();

  if (options.type) {
    builder = builder.withFilter(Filter('type').eq(options.type));
  }

  if (options.sortField) {
    const direction = options.sortDirection === 'DESC'
      ? Sort(options.sortField).desc()
      : Sort(options.sortField).asc();
    builder = builder.withSorting(direction);
  }

  return builder.build();
}

const query = buildServiceQuery({ type: 'COURSE', sortField: 'name', sortDirection: 'ASC' });
const response = await services.queryServices(query);
```

## See also

- [About Search, Query, and List Methods](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-search-query-and-list-methods.md)
- [About the Wix API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md)
- [About Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md)
- [Migrate from SDK Query Builders to Wix API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/migrate-from-sdk-query-builders-to-wix-api-query-language.md)