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

Syntax

function next(): Promise<EventsQueryResult>

next Parameters

This function does not take any parameters.

Returns

Fulfilled - The results of a Wix events query, containing the retrieved items. When you execute a query with the find() function, it returns a Promise that resolves to an EventsQueryResult 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
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 { wixEvents } from 'wix-events-backend';
2
3async function retrieveAllItems() {
4 let allItems = [];
5
6 const results = await wixEvents.queryEvents()
7 .limit(100)
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