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.
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.
function hasNext(): boolean;
const hasNext = results.hasNext(); // true
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
function hasPrev(): boolean;
const hasPrev = results.hasPrev(); // false
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
function next(): Promise<WixDataResult>;
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;
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.
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.
function prev(): Promise<WixDataResult>;
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;
}
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.