count( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Returns the number of items that match the query.

The count() method returns a Promise that resolves to the number of items that match the query. The Promise is rejected if count() is called with incorrect permissions or if any of the methods used to refine the query is invalid.

Calling the count() method triggers the beforeCount() and afterCount() hooks if they have been defined.

Use the options parameter to run count() without checking for permissions or without its registered hooks.

Any method that does not filter query results (e.g., ascending()) does not affect the result of count().

If you build a query and don't refine it with any WixDataQuery methods, count() returns the total number of items in the collection.

Note: You can also retrieve the number of query results by calling find() and setting the options.returnTotalCount property to true.

Method Declaration
Copy
Method Parameters
optionsWixDataReadOptions

Options to use when processing this operation.

Returns
Return Type:Promise<number>
Did this help?