Introduction

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

Returns an array of sessions that match the query.

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

JavaScript
import { sessions } from "wix-bookings-backend"; // ... sessions .querySessions() .ge("end.timestamp", "2021-01-01T00:00:00.000Z") .lt("start.timestamp", "2021-05-01T00:00:00.000Z") .limit(3) .find() .then((results) => { if (results.items.length > 0) { const items = results.items; // see below } else { // handle case where no matching items found } }) .catch((error) => { console.error(error); }); /* items: * [ * { * "end": { * "localDateTime": { * "year": 2021, * "monthOfYear": 1, * "dayOfMonth": 1, * "hourOfDay": 11, * "minutesOfHour": 0 * }, * "timestamp": "2021-01-01T09:00:00.000Z" * }, * "_id": "193Z...gIR", * "instanceOfRecurrence": "FREQ=WEEKLY;INTERVAL=1;BYDAY=FR", * "notes": "", * "recurringSessionId": "53616b1f0c3c45a1b282675acd248179-44539bfb63ae496693109b6cb3a65a65", * "scheduleId": "53616b1f-0c3c-45a1-b282-675acd248179", * "scheduleOwnerId": "b71df756-309f-468e-aec2-f82b9a9a9441", * "start": { * "localDateTime": { * "year": 2021, * "monthOfYear": 1, * "dayOfMonth": 1, * "hourOfDay": 10, * "minutesOfHour": 0 * }, * "timestamp": "2021-01-01T08:00:00.000Z" * }, * "status": "CONFIRMED", * "tags": [ * "GROUP" * ], * "type": "EVENT" * }, * { * "end": { * "localDateTime": { * "year": 2021, * "monthOfYear": 1, * "dayOfMonth": 4, * "hourOfDay": 18, * "minutesOfHour": 0 * }, * "timestamp": "2021-01-04T16:00:00.000Z" * }, * "_id": "4jO...deK", * "instanceOfRecurrence": "FREQ=WEEKLY;INTERVAL=1;BYDAY=FR", * "notes": "", * "recurringSessionId": "9299760d8a4a4f89b3481fc611f4be17-ecc4a5932acb4b7bb8c27c6ffb57fd49", * "scheduleId": "9299760d-8a4a-4f89-b348-1fc611f4be17", * "scheduleOwnerId": "e6b6108c-92bc-462b-937c-dab386909fd2", * "start": { * "localDateTime": { * "year": 2021, * "monthOfYear": 1, * "dayOfMonth": 4, * "hourOfDay": 10, * "minutesOfHour": 0 * }, * "timestamp": "2021-01-04T08:00:00.000Z" * }, * "status": "CONFIRMED", * "tags": [], * "type": "WORKING_HOURS" * }, * { * "end": { * "localDateTime": { * "year": 2021, * "monthOfYear": 1, * "dayOfMonth": 6, * "hourOfDay": 18, * "minutesOfHour": 0 * }, * "timestamp": "2021-01-06T16:00:00.000Z" * }, * "_id": "4jO...Wwv", * "instanceOfRecurrence": "FREQ=WEEKLY;INTERVAL=1;BYDAY=FR", * "notes": "", * "recurringSessionId": "9299760d8a4a4f89b3481fc611f4be17-3d6b38529f544674a4976eca75e584ca", * "scheduleId": "9299760d-8a4a-4f89-b348-1fc611f4be17", * "scheduleOwnerId": "e6b6108c-92bc-462b-937c-dab386909fd2", * "start": { * "localDateTime": { * "year": 2021, * "monthOfYear": 1, * "dayOfMonth": 6, * "hourOfDay": 10, * "minutesOfHour": 0 * }, * "timestamp": "2021-01-06T08:00:00.000Z" * }, * "status": "CONFIRMED", * "tags": [], * "type": "WORKING_HOURS" * } * ] */
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


querySessionQueryBuilderRead-only

Returns the SessionQueryBuilder object used to get the current results.

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