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 GroupsQueryResult
may change.
Syntax
function next(): Promise<GroupsQueryResult>
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 GroupsQueryResult
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 nextPageResults = currentPageResults.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 { groups } from "wix-groups-backend";23async function retrieveAllItems() {4 let allItems = [];56 let results = await groups.queryGroups()7 .limit(1000)8 .find();9 allItems = allItems.concat(results.items);1011 while (results.hasNext()) {12 results = await results.next();13 allItems = allItems.concat(results.items);14 }15 return allItems;16}17