Returns the number of items that match the query.
The count()
function 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 functions used to refine the
query is invalid.
Calling the count()
function 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 function 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
functions,
count()
returns the total number of items in the collection.
If you have already run a query with find()
, you can retrieve
the number of query results without calling count()
. The find()
function returns a Promise that resolves to a WixDataQueryResult
object, which has a totalCount
property whose value is the number of results.
An object containing options to use when processing this operation.