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

Syntax

function next(): Promise<MembershipsQueryResult>

next Parameters

This function does not take any parameters.

Returns

Fulfilled - The results of a create requests query, containing the retrieved items. When you execute a query with the find() function, it returns a Promise that resolves to a MembershipsQueryResult 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 nextPageResults = currentPageResults.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 { members } from "wix-groups-backend";
2
3async function retrieveAllItems() {
4 let allItems = [];
5
6 let results = await members.queryMemberships()
7 .limit(1000)
8 .find();
9 allItems = allItems.concat(results.items);
10
11 while (results.hasNext()) {
12 results = await results.next();
13 allItems = allItems.concat(results.items);
14 }
15 return allItems;
16}
17