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): EventsQueryBuilder
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 = events.queryEvents.limit(10);2
Create a query, add a
limit
, and run itCopy Code
1import { events } from 'wix-events.v2';23export async function myQueryFunction() {4 const results = await events.queryEvents().limit(10).find();56 if (results.items.length > 0) {7 const items = results.items;8 const firstItem = items[0];9 const pageSize = results.pageSize;10 const hasNext = results.hasNext();11 const hasPrev = results.hasPrev();12 const length = results.length;13 const query = results.query;1415 return items;16 } else {17 // Handle if no matching items found18 }19}20