queryResourceCatalog( )


Creates a query to retrieve extended resource information.

The queryResourceCatalog() function builds a query to retrieve a catalog of resources, including resources' related schedules and slugs, and returns a ResourceCatalogQueryBuilder object. The returned object contains the query definition, which is typically used to run the query using the find() function.

The ResourceCatalogQueryBuilder functions enable you to run, filter, and control which results a query returns.

Typically, you build a query using the resource catalog query function, refine the query by chaining ResourceCatalogQueryBuilder functions, and then execute the query by chaining the find() function.

The query runs with the following ResourceCatalogQueryBuilder defaults that you can override:

The following query builder functions are supported for queryResourceCatalog().

PropertySupported Filters                                                           
_ideq()
slugs.nameeq(), hasSome()

For a full description of the Resources object, see the object returned for the items array in ResourceCatalogQueryResult.

Note: Only users with the Bookings Admin role can query resources.

Method Declaration
Copy
function queryResourceCatalog(): ResourceCatalogQueryBuilder;
Request
This method does not take any parameters
Returns
Create a query, add an eq filter, and run it
JavaScript
import { resources } from "wix-bookings-backend"; // ... return resources .queryResourceCatalog() .eq("_id", "290113d8-e525-4619-a154-b0c45110348f") .find() .then((results) => { if (results.items.length > 0) { const items = results.items; const firstItem = items[0]; const totalCount = results.totalCount; const pageSize = results.pageSize; const currentPage = results.currentPage; const totalPages = results.totalPages; const hasNext = results.hasNext(); const hasPrev = results.hasPrev(); const length = results.length; const query = results.query; return results.items; } else { // handle case where no matching items found } }) .catch((error) => { console.error(error); }); /* Returns a promise that resolves to an array of resourceCatalog objects: * * [ * { * "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" * } * ] */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?