Search.../

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?

Get the next page of a query result

Copy Code
1const nextPage = oldResults.next()
2 .then((results) => {
3 return results;
4 })
5 .catch((error) => {
6 console.error(error);
7 });
Iterate through all pages of query results

This example demonstrates how to get all query results, bypassing the maximum limit of 1000.

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { contacts } from 'wix-crm-backend';
3
4export const retrieveAllItems = webMethod(Permissions.Anyone, async () => {
5 let allItems = [];
6
7 let results = await contacts.queryExtendedFields()
8 .limit(1000)
9 .find();
10 allItems = allItems.concat(results.items);
11
12 while (results.hasNext()) {
13 results = await results.next();
14 allItems = allItems.concat(results.items);
15 }
16
17 return allItems;
18});