Introduction

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

partialIncludes


partialIncludesbooleanRead-only

Indicates if referenced items have been trimmed from the results.

When including a property with multiple references, each returned item can include up to 50 referenced items. If there are more than 50 referenced items, only 50 will be returned and partialIncludes will be true.

To retrieve more than 50 referenced items, use the queryReferenced() function.

JavaScript
let partials = results.partialIncludes; // false
Did this help?

query


queryWixDataQueryRead-only

Returns the query used to get the current results.

Use the query property to create and run a new query by chaining additional WixDataQueryBuilder functions to it.

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?

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?

next( )


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 WixDataQueryResult may change.

Note: The next() function is not supported for Single Item Collections.

Method Declaration
Copy
function next(): Promise<WixDataQueryResult>;
Request
This method does not take any parameters
Returns
Return Type:Promise<WixDataQueryResult>
JavaScript
oldResults .next() .then((results) => { let newResults = results; let items = newResults.items; let firstItem = items[0]; let totalCount = newResults.totalCount; let pageSize = newResults.pageSize; let currentPage = newResults.currentPage; let totalPages = newResults.totalPages; let hasNext = newResults.hasNext(); let hasPrev = newResults.hasPrev(); let length = newResults.length; let query = newResults.query; }) .catch((error) => { let errorMsg = error.message; let code = error.code; });
Did this help?

prev( )


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.

Note: The prev() function is not supported for Single Item Collections.

Method Declaration
Copy
function prev(): Promise<WixDataQueryResult>;
Request
This method does not take any parameters
Returns
Return Type:Promise<WixDataQueryResult>
Get the previous page of a query result
JavaScript
oldResults .prev() .then((results) => { let newResults = results; let items = newResults.items; let firstItem = items[0]; let totalCount = newResults.totalCount; let pageSize = newResults.pageSize; let currentPage = newResults.currentPage; let totalPages = newResults.totalPages; let hasNext = newResults.hasNext(); let hasPrev = newResults.hasPrev(); let length = newResults.length; let query = newResults.query; }) .catch((error) => { let errorMsg = error.message; let code = error.code; });
Did this help?