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): SubmissionsQueryBuilder

limit Parameters

NAME
TYPE
DESCRIPTION
limit
Optional
number

Number of items to return, which is also the pageSize of the results object.

Returns

Was this helpful?

Add a limit to a query

Copy Code
1const query = submissions.querySubmissionsByNamespace.limit(10);
2
Create a query, add a limit, and run it

Copy Code
1import { submissions } from 'wix-forms.v2';
2
3export async function myQueryFunction() {
4 const results = await submissions
5 .querySubmissionsByNamespace()
6 .limit(10)
7 .find();
8
9 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;
17
18 return items;
19 } else {
20 // Handle if no matching items found
21 }
22}
23