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
1import { Permissions, webMethod } from 'wix-web-module';
2import { contacts } from 'wix-crm-backend';
3
4export const retrieveAllItems = webMethod(Permissions.Anyone, async () => {
5 let allItems = [];
6
7 let results = await contacts.queryContacts()
8 .limit(1000)
9 .find();
10 allItems = allItems.concat(results.items);
11
12 while (results.hasNext()) {
13 results = await results.next();
14 allItems = allItems.concat(results.items);
15 }
16
17 return allItems;
18});