Search...
limit( )
Developer Preview
Limits the number of items the query returns.
Description
The limit()
function defines the number of results a query returns in each page. Only one page of results is retrieved at a time.
You can use the next()
and prev()
functions to navigate the pages of a query result.
Syntax
function limit(limit: number): RequestsQueryBuilder
limit Parameters
NAME
TYPE
DESCRIPTION
limit
Optional
number
Number of items to return, which is also the pageSize
of the results object.
Returns
Return Type:
Was this helpful?
Add a
limit
to a queryCopy Code
1const query =2 backInStockNotifications.queryBackInStockNotificationRequests.limit(10);3
Create a query, add a
limit
, and run itCopy Code
1import { backInStockNotifications } from 'wix-ecom-backend';23export async function myQueryFunction() {4 const results = await backInStockNotifications5 .queryBackInStockNotificationRequests()6 .limit(10)7 .find();89 if (results.items.length > 0) {10 const items = results.items;11 const firstItem = items[0];12 const pageSize = results.pageSize;13 const hasNext = results.hasNext();14 const hasPrev = results.hasPrev();15 const length = results.length;16 const query = results.query;1718 return items;19 } else {20 // Handle if no matching items found21 }22}23