Introduction

When you execute a query with the find() function, it returns a Promise that resolves to a ResourceCatalogQueryResult object. This object contains the items that match the query, information about the query itself, and functions for paging through the query results.

Did this help?

currentPage


currentPagenumberRead-only

Returns the index of the current results page number.

The currentPage is a zero-based index of the current page of results.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

The currentPage property returns undefined if the query returned no results.

JavaScript
let resultPage = results.currentPage; // 0
Did this help?

items


itemsArray<ResourceQueryResults>Read-only

Returns an array of resources, slugs, and schedules that match the query.

The current page of resources, slugs, and schedules retrieved by the query.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

When no items match the query, the array is empty.

Perform a query and get the resource catalog items from the result
JavaScript
import { resources } from "wix-bookings-backend"; // ... resources .queryResourceCatalog() .find() .then((results) => { if (results.items.length > 0) { let items = results.items; // see below } else { // handle case where no matching items found } }) .catch((error) => { console.error(error); }); /* items: * * [ * { * "resource": { * "_id": "2015d816-4ae1-4eb3-8f93-3c97441b5832", * "name": "John Doe", * "email": "john@doe.com", * "phone": "555 4567", * "description": "Fitness Instructor", * "tags": [ * "staff" * ], * "scheduleIds": [ * "3ade521f-ba4e-4782-977c-0efe84e7c797" * ], * "status": "UPDATED" * }, * "schedules": [ * { * "availability": { * "linkedSchedules": [], * "start": "2021-01-01T06:00:00Z" * }, * "_id": "3ade521f-ba4e-4782-977c-0efe84e7c797", * "scheduleOwnerId": "2015d816-4ae1-4eb3-8f93-3c97441b5832" * } * ], * "slugs": [ * { * "_createdDate": "2021-04-12T11:49:50.416Z", * "name": "john-doe-6" * } * ] * }, * { * "resource": { * "_id": "290113d8-e525-4619-a154-b0c45110348f", * "name": "Jack Brown", * "email": "jbrown@test.com", * "phone": "555 4321", * "description": "Instructor", * "tags": [ * "staff" * ], * "scheduleIds": [ * "95d8769e-ce74-4fe2-ab79-ab24e5c14e0e" * ], * "status": "UPDATED" * }, * "schedules": [ * { * "availability": { * "linkedSchedules": [ * { * "scheduleId": "9299760d-8a4a-4f89-b348-1fc611f4be17" * } * ], * "start": "2021-04-18T07:22:42.274Z" * }, * "_id": "95d8769e-ce74-4fe2-ab79-ab24e5c14e0e", * "scheduleOwnerId": "290113d8-e525-4619-a154-b0c45110348f" * } * ], * "slugs": [ * { * "_createdDate": "2021-04-18T07:22:43.392Z", * "name": "jack-brown" * } * ] * }, * { * "resource": { * "_id": "4c17a7cc-c1d8-4fd1-aacd-0768df100b6d", * "name": "Joe Blue", * "email": "jb@gmail.com", * "description": "Joe is a good guy", * "tags": [ * "staff" * ], * "scheduleIds": [ * "d165e99c-bae4-4e6f-a064-7d4108902be0" * ], * "status": "UPDATED" * }, * "schedules": [ * { * "availability": { * "linkedSchedules": [ * { * "scheduleId": "9299760d-8a4a-4f89-b348-1fc611f4be17" * } * ], * "start": "2021-03-24T16:08:16.832Z" * }, * "_id": "d165e99c-bae4-4e6f-a064-7d4108902be0", * "scheduleOwnerId": "4c17a7cc-c1d8-4fd1-aacd-0768df100b6d" * } * ], * "slugs": [ * { * "_createdDate": "2021-01-18T10:41:31.652Z", * "name": "joe-blue" * } * ] * }, * { * "resource": { * "_id": "b5147aad-f117-4f8e-90fe-d61043112c94", * "name": "Joe Smith", * "email": "js@s.com", * "phone": "8888", * "description": "", * "tags": [ * "staff" * ], * "scheduleIds": [ * "892714a8-01f6-491c-b07c-89ae4f416dc0" * ], * "status": "UPDATED" * }, * "schedules": [ * { * "availability": { * "linkedSchedules": [ * { * "scheduleId": "9299760d-8a4a-4f89-b348-1fc611f4be17" * } * ], * "start": "2021-01-01T06:00:00Z" * }, * "_id": "892714a8-01f6-491c-b07c-89ae4f416dc0", * "scheduleOwnerId": "b5147aad-f117-4f8e-90fe-d61043112c94" * } * ], * "slugs": [ * { * "_createdDate": "2021-01-25T18:10:42.682Z", * "name": "joe-smith" * } * ] * } * ] */
Did this help?

length


lengthnumberRead-only

Returns the number of items in the current results page.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

JavaScript
let resultLength = results.length; // 20
Did this help?

pageSize


pageSizenumberRead-only

Returns the query page size.

The page size is defined by the limit() function, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

JavaScript
let resultPageSize = results.pageSize; // 50
Did this help?

query


Returns the ResourceCatalogQueryBuilder object used to get the current results.

Use the query property to create and run a new query by chaining additional ResourceCatalogQueryBuilder functions to it. You can only filter on properties that have not already been used in the previous query.

JavaScript
let resultQuery = results.query;
Did this help?