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

Code Example

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.

Code Example

Copy Code
1async function retrieveAllItems(phrase){
2 let allItems = [];
3
4 let results = await wixData.query("myCollection")
5 .limit(1000)
6 .find();
7
8 allItems.push(results.items);
9
10 while(results.hasNext()) {
11 results = await results.next();
12 allItems.push(results.items);
13 }
14 return allItems;
15}
16