> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: limit(limit: number) # Method package: wixData # Method menu location: wixData --> WixDataQuery --> limit # Method Link: https://dev.wix.com/docs/velo/apis/wix-data/wix-data-query/limit.md # Method Description: Limits the number of items the query returns. 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()`](wix-data.WixDataQueryResult.html#next) and [`prev()`](wix-data.WixDataQueryResult.html#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`. Note that for some Wix app collections, the maximum value `limit()` can accept is less than `1000`. For example, the maximum limit for the Wix `Stores/Product` collection is 100. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Add a limit to a query ```javascript let newQuery = query.limit(10); ``` ## Create a query, add a limit, and run it ```javascript import wixData from 'wix-data'; // ... wixData.query("myCollection") .limit(10) .find() .then((results) => { if(results.items.length > 0) { let items = results.items; let firstItem = items[0]; let totalCount = results.totalCount; let pageSize = results.pageSize; let currentPage = results.currentPage; let totalPages = results.totalPages; let hasNext = results.hasNext(); let hasPrev = results.hasPrev(); let length = results.length; let query = results.query; } else { // handle case where no matching items found } }) .catch((error) => { let errorMsg = error.message; let code = error.code; }); ``` ## Create a query, add a limit, and run it ```javascript import wixData from 'wix-data'; // ... wixData.query("myCollection") .eq("status", "active") .gt("age", 25) .ascending("last_name", "first_name") .limit(10) .find() .then((results) => { if(results.items.length > 0) { let items = results.items; let firstItem = items[0]; let totalCount = results.totalCount; let pageSize = results.pageSize; let currentPage = results.currentPage; let totalPages = results.totalPages; let hasNext = results.hasNext(); let hasPrev = results.hasPrev(); let length = results.length; let query = results.query; } else { // handle case where no matching items found } }) .catch((error) => { let errorMsg = error.message; let code = error.code; }); ``` ## Iterate through all pages of query results ```javascript async function retrieveAllItems() { let results = await wixData.query("myCollection") .limit(1000) .find(); let allItems = results.items; while (results.hasNext()) { results = await results.next(); allItems = allItems.concat(results.items); } return allItems; } ``` ---