Search.../

length

Returns the number of items in the current page of results.

Description

length returns just the number of items in the current page, not the total number of items that match the query. For the total number of items that match the query, see totalCount. The page size is defined by the limit() function and can be retrieved using the pageSize property. You can use the next() and prev() functions returned by posts to navigate the pages of a query result.

Type:

number

Was this helpful?

Get length from a query result

Copy Code
1const resultLength = results.length;
2
Perform a query and get length from the result

Copy Code
1import { posts } from 'wix-blog-backend';
2
3export async function myQueryFunction() {
4 const results = await posts.queryPosts().find();
5
6 return results.length;
7}
8