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<object>Read-only

Returns the items that match the query.

The current page of items 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
let items = results.items; /* * [ * { * "_id": "1234", * "_owner": "f45jf8d2-grkj-2opd-4ovk-9rfj4wo5tvj3", * "_createdDate": "2017-05-29T08:35:52.344Z", * "_updatedDate": "2017-05-29T08:35:52.344Z", * "title": "Dr.", * "first_name": "Jane", * "last_name": "Doe", * "status": "active" * }, * { * "_id": "5678", * "_owner": "f45jf8d2-grkj-2opd-4ovk-9rfj4wo5tvj3", * "_createdDate": "2017-05-25T12:48:56.572Z", * "_updatedDate": "2017-05-29T07:30:15.869Z", * "title": "Mr.", * "first_name": "John", * "last_name": "Doe", * "status": "active" * } * ] */
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 query used to get the current results.

JavaScript
let resultQuery = results.query; /* resultQuery: * * "filterTree": { * "$and": [ * { * "status": { * "$hasSome": [ * "PENDING_APPROVAL", * "CONFIRMED", * "DECLINED", * "CANCELED", * "PENDING_CHECKOUT", * "PENDING" * ] * } * } * ] * }, * "invalidArguments": [], * "sort": [ * { * "fieldName": "created", * "order": "DESC" * } * ], * "paging": { * "offset": 9 * }, * "pagingMethod": "OFFSET" * */
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?

hasNext( )


Indicates if the query has more results.

Method Declaration
Copy
function hasNext(): boolean;
Request
This method does not take any parameters
Returns
Return Type:boolean
JavaScript
let hasNext = results.hasNext(); // true
Did this help?

hasPrev( )


Indicates the query has previous results.

Method Declaration
Copy
function hasPrev(): boolean;
Request
This method does not take any parameters
Returns
Return Type:boolean
Get whether the query result object has previous results
JavaScript
let hasPrev = results.hasPrev(); // false
Did this help?