> 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: Migrate from SDK Query Builders to Wix API Query Language

## Article: Migrate from SDK Query Builders to Wix API Query Language

## Article Link: 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

## Article Content:

# Migrate from SDK Query Builders to Wix API Query Language

The Wix JavaScript SDK is transitioning from query builder methods to query methods that use the Wix API Query Language. This change provides a more consistent and powerful querying experience across all Wix APIs.

## What's changed

Previously, SDK query methods used a builder pattern where you chained methods to build your query. For example, methods like `queryBookings()`, `querySessions()`, and `queryResourceCatalog()` returned query builder objects with methods like `.eq()`, `.hasSome()`, `.limit()`, and `.find()`.

The new approach uses 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), where you pass a query object directly to the query method. This provides more flexibility and consistency across different Wix APIs.

## Backward compatibility

The existing query builder methods continue to work. However, we strongly recommend migrating to the new query methods that use Wix API Query Language as this is our path forward for SDK development.

Updating your code now ensures long-term compatibility and gives you access to the latest features and improvements.

## Code comparison

Here's how the same query looks with both approaches:

### New query method with Wix API Query Language

```javascript
import { menus } from '@wix/restaurants';

// Query menus with visibility true and limit to 10 results
const results = await menus.queryMenus({
  query: {
    filter: {
      visible: true,
      createdDate: { $gte: '2024-01-01T00:00:00.000Z' }
    },
    sort: [{ fieldName: 'createdDate', order: 'DESC' }],
    cursorPaging: {
      limit: 10
    }
  }
});

console.log(results.menus);
```

### Old query method with query builders

```javascript
import { menus } from '@wix/restaurants';

// Query menus with visibility true and limit to 10 results
const results = await menus.queryMenus()
  .eq('visible', true)
  .ge('createdDate', '2024-01-01T00:00:00.000Z')
  .descending('createdDate')
  .limit(10)
  .find();

console.log(results.items);
```

## How to migrate your code

Follow these steps to update your query methods:

### Step 1 | Identify query methods with the query builder

Look for code patterns that include:
- A method called `query<Something>()` followed by chained methods.
- Methods like `.eq()`, `.hasSome()`, `.limit()`, `.skip()`, `.ascending()`, or `.descending()`.
- A final `.find()` call.

### Step 2 | Convert the query structure

Map your query builder chain into a query object. Below are some common mapping examples: 

#### Filters:

| Old | New |
|-----|-----|
| `.eq('field', 'value')` | `filter: { field: 'value' }` or `filter: { field: { $eq: 'value' } }` |
| `.hasSome('field', ['val1', 'val2'])` | `filter: { field: { $in: ['val1', 'val2'] } }` |
| `.ge('field', 'value')` | `filter: { field: { $gte: 'value' } }` |
| `.lt('field', 'value')` | `filter: { field: { $lt: 'value' } }` |

#### Sorting:

| Old | New |
|-----|-----|
| `.ascending('field')` | `sort: [{ fieldName: 'field', order: 'ASC' }]` |
| `.descending('field')` | `sort: [{ fieldName: 'field', order: 'DESC' }]` |

#### Paging: 

| Old | New |
|-----|-----|
| `.limit(50)` | `paging: { limit: 50 }` or `cursorPaging: { limit: 50 }` |
| `.skip(20)` | `paging: { offset: 20, limit: X }` |
| `.skipTo(cursor)` | `cursorPaging: { cursor: "..." }` |

> **Note:**
> The new query methods can support either cursor-based or offset-based paging. For offset-based paging, if you specify `offset`, you must also include `limit`. For cursor paging, the cursor value is a string token returned from previous query return values. Learn more about [paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging?apiView=SDK.md#paging). 
    

### Step 3 | Update the method call

Replace the old query method with the new one and remove the `.find()` call:

#### Old query method

```javascript
const results = await bookings.queryBookings()
  .eq('status', 'CONFIRMED')
  .ge('startTime', '2024-01-01T00:00:00.000Z')
  .limit(20)
  .find();
```

#### New query method

```javascript
const results = await bookings.queryBookings({
  query: {
    filter: { 
      status: 'CONFIRMED',
      startTime: { $gte: '2024-01-01T00:00:00.000Z' }
    },
    cursorPaging: { limit: 20 }
  }
});
```

### Step 4 | Test and deploy

After updating, make sure to test your code in your development environment before publishing your site or deploying your project.


To learn more about the API Query Language syntax, see [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?apiView=SDK.md) and [About Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging?apiView=SDK.md).

If you prefer building queries with a chainable syntax, the SDK provides [query builder utilities](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-query-builder-utilities.md) that let you compose Wix API Query Language objects using method chaining.