Search...
hasNext( )
Indicates if the aggregation 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 aggregate result object has more results
Copy Code
1let hasNext = results.hasNext(); // true
Run an aggregation and get whether the aggregate result object has more results
Copy Code
1import wixData from 'wix-data';23wixData.aggregate("PopulationData")4 .group("state")5 .max("population")6 .run()7 .then((results) => {8 let hasNext = results.hasNext(); // false9 });
Iterate through all pages of aggregate results
Copy Code
1let results = await wixData.aggregate("Cities")2 .group("city")3 .limit(3)4 .run();56console.log(results.items);78while(results.hasNext()) {9 console.log("---▼ Next Page ▼---");10 results = await results.next();11 console.log(results.items);12}1314/* Logs:15 * [{"_id":"San Diego"},{"_id":"Orlando"},{"_id":"San Francisco"}]16 * ---▼ Next Page ▼---17 * [{"_id":"Buffalo"},{"_id":"Miami"},{"_id":"Los Angeles"}]18 * ---▼ Next Page ▼---19 * [{"_id":"Miami"}]20 */