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 and can be retrieved using the pageSize property. You can use the next() and prev() functions returned by serviceOptionsAndVariants to navigate the pages of a query result. If items are added or removed between calls to next(), the values returned by ServiceOptionsAndVariantssQueryBuilder may change.

Syntax

function next(): Promise<ServiceOptionsAndVariantsListQueryResult>

next Parameters

This function does not take any parameters.

Returns

Was this helpful?

Get next from a query result

Copy Code
1const nextPage = results.next();
2
Perform a query and get next from the result

Copy Code
1import { serviceOptionsAndVariants } from 'wix-bookings.v2';
2
3export async function myQueryFunction() {
4 const results = await serviceOptionsAndVariants
5 .queryServiceOptionsAndVariants()
6 .find();
7
8 return results.next();
9}
10
Iterate through all pages of query results

Copy Code
1import { serviceOptionsAndVariants } from 'wix-bookings.v2';
2
3export async function myQueryFunction() {
4 let allItems = [];
5
6 const results = await serviceOptionsAndVariants
7 .queryServiceOptionsAndVariants()
8 .limit(1000)
9 .find();
10 allItems.push(results.items);
11
12 while (results.hasNext()) {
13 results = await results.next();
14 allItems.push(results.items);
15 }
16
17 return allItems;
18}
19