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.
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"
* }
* ]
* }
* ]
*/
let resultLength = results.length; // 20
let resultPageSize = results.pageSize; // 50
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.
let resultQuery = results.query;
Returns the total number of items that match the query.
The totalCount
returns the total number of items that match the query,
not just the number of items in the current page.
let resultCount = results.totalCount; // 150
let resultPages = results.totalPages; // 3
Indicates if the query has more results.
function hasNext(): boolean;
let hasNext = results.hasNext(); // true
Indicates the query has previous results.
function hasPrev(): boolean;
let hasPrev = results.hasPrev(); // false
Retrieves the next page of query results.
The next()
function retrieves the next page of query 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.
If items are added or removed between calls to next()
the values returned
by ResourceCatalogQueryResult
may change.
function next(): Promise<ResourceCatalogQueryResult>;
oldResults
.next()
.then((results) => {
const newResults = results;
const items = newResults.items;
const firstItem = items[0];
const totalCount = newResults.totalCount;
const pageSize = newResults.pageSize;
const currentPage = newResults.currentPage;
const totalPages = newResults.totalPages;
const hasNext = newResults.hasNext();
const hasPrev = newResults.hasPrev();
const length = newResults.length;
const query = newResults.query;
})
.catch((error) => {
console.error(error);
});
Retrieves the previous page of query results.
The prev()
function retrieves the previous page of query 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.
If items are added or removed between calls to prev()
the values returned
may change.
function prev(): Promise<ResourceCatalogQueryResult>;
oldResults
.prev()
.then((results) => {
const newResults = results;
const items = newResults.items;
const firstItem = items[0];
const totalCount = newResults.totalCount;
const pageSize = newResults.pageSize;
const currentPage = newResults.currentPage;
const totalPages = newResults.totalPages;
const hasNext = newResults.hasNext();
const hasPrev = newResults.hasPrev();
const length = newResults.length;
const query = newResults.query;
})
.catch((error) => {
console.error(error);
});