Search.../

hasNext( )

Indicates if the query has more results.

Syntax

function hasNext(): boolean

hasNext Parameters

This function does not take any parameters.

Returns

true if there are more results.

Return Type:

boolean

Was this helpful?

Get whether the query result object has more results

Copy Code
1let hasNext = results.hasNext(); // true
Iterate through all pages of query results

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

Copy Code
1async function retrieveAllItems() {
2 let results = await wixData.query("myCollection")
3 .limit(1000)
4 .find();
5 let allItems = results.items;
6 while (results.hasNext()) {
7 results = await results.next();
8 allItems = allItems.concat(results.items);
9 }
10 return allItems;
11}