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

Syntax

function next(): Promise<PublicPlansQueryResult>

next Parameters

This function does not take any parameters.

Returns

Fulfilled - A query result object with the next page of query results. Rejected - The errors that caused the rejection.

Return Type:

Was this helpful?

Get the next page of a query result

Copy Code
1oldResults.next()
2 .then((results) => {
3 const newResults = results;
4 const items = newResults.items;
5 const firstItem = items[0];
6 const totalCount = newResults.totalCount;
7 const pageSize = newResults.pageSize;
8 const currentPage = newResults.currentPage;
9 const totalPages = newResults.totalPages;
10 const hasNext = newResults.hasNext();
11 const hasPrev = newResults.hasPrev();
12 const length = newResults.length;
13 const query = newResults.query;
14 })
15 .catch((error) => {
16 const queryError = error;
17 });
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 wixPricingPlansBackend from 'wix-pricing-plans-backend';
2
3async function retrieveAllItems() {
4 const allItems = [];
5
6 const results = await wixPricingPlansBackend.queryPublicPlans()
7 .limit(1000)
8 .find();
9 allItems.push(results.items);
10
11 while (results.hasNext()) {
12 results = await results.next();
13 allItems.push(results.items);
14 }
15 return allItems;
16}
17