Introduction

When you execute a query with the find() function, it returns a Promise that resolves to a BookingsQueryResult 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<Booking>Read-only

Returns an array of bookings that match the query.

The current page of bookings 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 booking array is empty.

Perform a query and get the booking items from the result
JavaScript
import { bookings } from "wix-bookings-backend"; // ... bookings .queryBookings() .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: * [ * { * "_id": "3bab599d-c032-4f4c-89b1-c73dc51f013c", * "bookedEntity": { * "serviceId": "57daccbf-0fc9-4f3d-9c9e-1969947f33fa", * "scheduleId": "b5c9d6f1-8606-4378-9f4b-7e94d98de91f", * "setOfSessions": { * "firstSessionStart": "2021-01-20T14:30:00Z", * "lastSessionEnd": "2021-03-24T14:30:00Z" * }, * "title": "12 Part Meditation Course", * "location": { * "locationType": "OWNER_BUSINESS" * }, * "rate": { * "labeledPriceOptions": { * "general": { * "amount": "5000", * "currency": "USD", * "downPayAmount": "50" * } * } * }, * "tags": [ * "COURSE" * ] * }, * "bookedResources": [ * { * "_id": "76570209-101f-409b-af97-b445bdb63125", * "name": "John Smith", * "email": "jsmith@gmail.com" * } * ], * "status": "CONFIRMED", * "_createdDate": "2021-01-11T08:46:20.703Z", * "bookingSource": { * "platform": "WEB", * "actor": "CUSTOMER", * "appDefId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97", * "appName": "Wix Bookings" * }, * "formInfo": { * "paymentSelection": [ * { * "rateLabel": "general", * "numberOfParticipants": 1 * } * ], * "additionalFields": [ * { * "_id": "00000000-0000-0000-0000-000000000008", * "label": "Add Your Message", * "valueType": "LONG_TEXT" * } * ], * "contactDetails": { * "contactId": "593da82a-9718-4d43-9db0-8414320b3aa0", * "firstName": "Frank White", * "email": "frankw@wmail.com", * "phone": "555 3456", * "timeZone": "America/New_York", * "countryCode": "US" * } * }, * "paymentDetails": { * "balance": { * "finalPrice": { * "amount": "5000", * "currency": "USD", * "downPayAmount": "50" * }, * "amountReceived": "5000" * }, * "state": "COMPLETE", * "wixPayMultipleDetails": [ * { * "txId": "eb804fc3-ecab-49c9-8785-0e12d71aaff8", * "orderId": "6fa06198-1c39-4cf0-91db-a01b10720f56", * "orderAmount": "4950", * "orderStatus": "UNDEFINED", * "orderApprovalTime": "2021-01-11T08:47:44.757Z", * "paymentVendorName": "inPerson" * }, * { * "orderId": "aedcae46-844b-4091-b174-cf90f102629f", * "orderAmount": "50", * "orderStatus": "UNDEFINED" * } * ] * } * }, * { * "_id": "7125331e-75e6-4889-809a-5dea10648b30", * "bookedEntity": { * "serviceId": "b71df756-309f-468e-aec2-f82b9a9a9441", * "scheduleId": "53616b1f-0c3c-45a1-b282-675acd248179", * "singleSession": { * "sessionId": * "193ZPR9ppP9emJUCLevcLf6orynNEIDt5nc0520xjGQILnPPaF5s62yK3BWz7ExgIRM1* HunZjEPUQ0IeScwcTFJNXEmLG2g6Q8tvUJQZrPhU6XKhVrlLZraC3YcVfygADFiCPyyy5* IVhgtDpF30FnQDoG8I60n21QAlhok4LHNlkBszoGZ67jGMeDOqxS8PXZgJx87ByXwfgsN* 3AfXbndYxESrFnttLnRSFzcsolPAjYhaRCdJBhUj8rAoBoj71MgiFi4Tw3FDyVZz2OeOH* GmfQwRi0ELuqZvw0Y5tmMXrIKa48SvG8sr2MyOQsaIbMHy8YX1Q8anAgfdt", * "start": "2021-01-22T10:30:00Z", * "end": "2021-01-22T11:00:00Z" * }, * "title": "Yoga Class", * "location": { * "locationType": "OWNER_BUSINESS" * }, * "rate": { * "labeledPriceOptions": { * "general": { * "amount": "50", * "currency": "USD", * "downPayAmount": "0" * } * } * }, * "tags": [ * "GROUP" * ] * }, * "bookedResources": [ * { * "_id": "76570209-101f-409b-af97-b445bdb63125", * "name": "John Smith", * "email": "jsmith@gmail.com" * } * ], * "status": "PENDING_CHECKOUT", * "_createdDate": "2021-01-11T08:45:00.214Z", * "attendanceInfo": { * "attendanceStatus": true, * "numberOfAttendees": 1 * }, * "bookingSource": { * "platform": "WEB", * "actor": "CUSTOMER", * "appDefId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97", * "appName": "Wix Bookings" * }, * "formInfo": { * "paymentSelection": [ * { * "rateLabel": "general", * "numberOfParticipants": 1 * } * ], * "additionalFields": [ * { * : "00000000-0000-0000-0000-000000000008", * "value": "Cant wait to start", * "label": "Add Your Message", * "valueType": "LONG_TEXT", * "_id": "00000000-0000-0000-0000-000000000008" * } * ], * "contactDetails": { * "contactId": "a6d4c19e-1882-4e29-9eb3-411e1aeeb874", * "firstName": "Joe Green", * "email": "JoeGreen@hmail.com", * "phone": "9998765", * "timeZone": "America/New_York", * "countryCode": "US" * } * }, * "paymentDetails": { * "balance": { * "finalPrice": { * "amount": "50", * "currency": "USD", * "downPayAmount": "0" * }, * "amountReceived": "0" * }, * "state": "PENDING_CASHIER", * "wixPayMultipleDetails": [ * { * "orderId": "dd702e88-68e0-4faa-94b2-4996136a9828", * "orderAmount": "50", * "orderStatus": "UNDEFINED" * } * ] * }, * } * ] */
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


queryBookingsQueryBuilderRead-only

Returns the BookingsQueryBuilder object used to get the current results.

Use the query property to create and run a new query by chaining additional BookingsQueryBuilder 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?

totalCount


totalCountnumberRead-only

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.

JavaScript
let resultCount = results.totalCount; // 150
Did this help?

totalPages


totalPagesnumberRead-only

Returns the total number of pages the query produced.

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 resultPages = results.totalPages; // 3
Did this help?