beforeCount( )


A hook that is triggered before a count() operation.

The beforeCount() hook runs when:

  • The count() function is called.
  • The collection is viewed in the CMS.

Return a query or a Promise that resolves to a query from the beforeCount() function. The returned query will be used as the query for the count() operation.

Often, you will modify the query that is received in the query parameter by calling one or more WixDataQuery functions.

If the returned value is of the wrong type, the value is ignored.

A rejected Promise blocks the call to count() and also calls the onFailure() hook if it has been registered.

Because the beforeCount() hook is called before count() is executed, it can affect how items are counted or block the count().

Method Declaration
Copy
Method Parameters
queryWixDataQueryRequired

The original query as defined by count().


contextHookContextRequired

Contextual information about the hook.

Returns
Return Type:Promise<WixDataQuery> | WixDataQuery
Did this help?