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, can be retrieved using the pageSize property, and navigating through pages is done with the prev() and next() functions.

If items are added or removed between calls to next() the values returned by BookingsQueryResult may change.

Syntax

function next(): Promise<SessionQueryResult>

next Parameters

This function does not take any parameters.

Returns

Fulfilled - A query result object with the next page of query results. Rejected - The errors that caused the rejection.

Return Type:

Was this helpful?

Get the next page of a query result

Copy Code
1firstResults.next()
2 .then((results) => {
3 const newResults = results;
4 const items = newResults.items;
5 const firstItem = items[0];
6 const totalCount = newResults.totalCount;
7 const pageSize = newResults.pageSize;
8 const currentPage = newResults.currentPage;
9 const totalPages = newResults.totalPages;
10 const hasNext = newResults.hasNext();
11 const hasPrev = newResults.hasPrev();
12 const length = newResults.length;
13 const query = newResults.query;
14 })
15 .catch((error) => {
16 console.error(error);
17 });
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 { sessions } from "wix-bookings-backend";
2
3async function retrieveAllItems() {
4 let allItems = [];
5
6 let results = await sessions.querySessions()
7 .ge("end.timestamp", "2021-01-01T00:00:00.000Z")
8 .lt("start.timestamp", "2021-05-01T00:00:00.000Z")
9 .limit(100)
10 .find();
11 allItems = allItems.concat(results.items);
12
13 while (results.hasNext()) {
14 results = await results.next();
15 allItems = allItems.concat(results.items);
16 }
17 return allItems;
18}
19