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 posts
to navigate the pages of a query result.
If items are added or removed between calls to next()
, the values returned by PostsQueryBuilder
may change.
Syntax
function next(): Promise<PostsQueryResult>
next Parameters
This function does not take any parameters.
Returns
Return Type:
Promise<>
Was this helpful?
Get
next
from a query resultCopy Code
1const nextPage = results.next();2
Perform a query and get
next
from the resultCopy Code
1import { posts } from 'wix-blog-backend';23export async function myQueryFunction() {4 const results = await posts.queryPosts().find();56 return results.next();7}8
Iterate through all pages of query results
Copy Code
1import { posts } from 'wix-blog-backend';23export async function myQueryFunction() {4 let allItems = [];56 const results = await posts.queryPosts().limit(1000).find();7 allItems.push(results.items);89 while (results.hasNext()) {10 results = await results.next();11 allItems.push(results.items);12 }1314 return allItems;15}16