Search.../

limit( )

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. The next() and prev() functions are used to navigate the pages of a query result.

By default, limit is set to 50.

The maximum value that limit() can accept is 1000.

Syntax

function limit(limit: number): PublicPlansQueryBuilder

limit Parameters

NAME
TYPE
DESCRIPTION
limit
number

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

Returns

A PublicPlansQueryBuilder object representing the refined query.

Was this helpful?

Add a limit to a query

Copy Code
1const query = wixPricingPlansBackend.queryPublicPlans().limit(10);
Create a query, add a limit, and run it

Copy Code
1import wixPricingPlansBackend from 'wix-pricing-plans-backend';
2
3// ...
4
5wixPricingPlansBackend.queryPublicPlans()
6 .limit(10)
7 .find()
8 .then((results) => {
9 if (results.items.length > 0) {
10 const items = results.items;
11 const firstItem = items[0];
12 const totalCount = results.totalCount;
13 const pageSize = results.pageSize;
14 const currentPage = results.currentPage;
15 const totalPages = results.totalPages;
16 const hasNext = results.hasNext();
17 const hasPrev = results.hasPrev();
18 const length = results.length;
19 const query = results.query;
20 } else {
21 // handle case where no matching items found
22 }
23 })
24 .catch((error) => {
25 const queryError = error;
26 });