next( )
Retrieves the next page of query results.
Description
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 ExtendedFieldsQueryResult
may change.
Syntax
function next(): Promise<ExtendedFieldsQueryResult>
next Parameters
This function does not take any parameters.
Returns
Fulfilled - The results of a contacts query, containing the retrieved items.
When you execute a query with the find()
function, it returns a Promise that resolves to a ExtendedFieldsQueryResult
object.
This object contains the items that match the query, information about the
query itself, and functions for paging through the query results.
Return Type:
Was this helpful?
1const nextPage = oldResults.next()2 .then((results) => {3 return results;4 })5 .catch((error) => {6 console.error(error);7 });
This example demonstrates how to get all query results, bypassing the maximum limit of 1000.
1import { Permissions, webMethod } from 'wix-web-module';2import { contacts } from 'wix-crm-backend';34export const retrieveAllItems = webMethod(Permissions.Anyone, async () => {5 let allItems = [];67 let results = await contacts.queryExtendedFields()8 .limit(1000)9 .find();10 allItems = allItems.concat(results.items);1112 while (results.hasNext()) {13 results = await results.next();14 allItems = allItems.concat(results.items);15 }1617 return allItems;18});