Introduction

When you execute a data operation like find(), distinct(), run() or queryReferences(), it returns a Promise that resolves to a WixDataResult 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?

hasNext( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

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
const hasNext = results.hasNext(); // true
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

hasPrev( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

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
const hasPrev = results.hasPrev(); // false
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

next( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves the next page of query results.

The next() method retrieves the next page of query results.

The page size is defined by the limit() method, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() methods.

If items are added or removed between calls to next() the values returned may change.

Note: The next() method is not supported for single-item collections.

Method Declaration
Copy
function next(): Promise<WixDataResult>;
Request
This method does not take any parameters
Returns
Return Type:Promise<WixDataResult>
JavaScript
async function queryNextPage(oldResults) { const newResults = await oldResults.next(); const items = newResults.items; const firstItem = items[0]; const pageSize = newResults.pageSize; const currentPage = newResults.currentPage; const hasNext = newResults.hasNext(); const hasPrev = newResults.hasPrev(); const length = newResults.length; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

prev( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves the previous page of query results.

The prev() method retrieves the previous page of query results.

The page size is defined by the limit() method, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() methods.

If items are added or removed between calls to prev() the values returned may change.

Note: The prev() method is not supported for single-item collections.

Method Declaration
Copy
function prev(): Promise<WixDataResult>;
Request
This method does not take any parameters
Returns
Return Type:Promise<WixDataResult>
Get the previous page of a query result
JavaScript
async function queryPreviousPage(oldResults) { const newResults = await oldResults.prev(); const items = newResults.items; const firstItem = items[0]; const pageSize = newResults.pageSize; const currentPage = newResults.currentPage; const hasNext = newResults.hasNext(); const hasPrev = newResults.hasPrev(); const length = newResults.length; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?