count( )


Refines a WixDataAggregate to contain the item count of each group in the aggregation.

The count() function refines a WixDataAggregate to contain the item count in each of the aggregate's groups.

When the aggregation is run, the returned WixDataAggregateResult object contains items with the following additional key:value pair:

  • The key is named "count".
  • The value is the count of items aggregated in the group.

Note: Aggregations can only be used on collections you have created. They cannot be used on Wix App Collections.

Method Declaration
Copy
function count(): WixDataAggregate;
Request
This method does not take any parameters
Returns
Return Type:WixDataAggregate
JavaScript
let newAggregate = aggregate.count();
Did this help?

descending( )


Adds a sort to an aggregation, sorting by the items or groups by the specified properties in descending order.

The descending() function refines a WixDataAggregate to sort the resulting items or groups in descending order. If you specify more than one property, descending() sorts the results in descending order by each property in the order they are listed.

You can sort the following types:

  • Number: Sorts numerically.
  • Date: Sorts by date and time.
  • String: Sorts lexicographically, so "abc" comes after "XYZ".
  • Reference: Compares by the ID of the referenced item as a String.

If a property contains a number as a String, that value will be sorted alphabetically and not numerically. Items that do not have a value for the specified sort property are ranked lowest.

Note: Aggregations can only be used on collections you have created. They cannot be used on Wix App Collections.

Method Declaration
Copy
Method Parameters
propertyNameArray<string>Required

The properties used in the sort.

Returns
Return Type:WixDataAggregate
JavaScript
Did this help?

filter( )


Filters out items from being used in an aggregation.

The filter() function refines a WixDataAggregate so that it only includes items from the aggregate's collection which match the specified filter criteria.

To create a filter, use the wix-data filter() function.

Filtering using filter() takes place before grouping is performed on the aggregation. To filter grouped results, use the having() function.

Note: Aggregations can only be used on collections you have created. They cannot be used on Wix App Collections.

Method Declaration
Copy
Method Parameters
filterWixDataFilterRequired

The filter to use to filter out items from being used in the aggregation.

Returns
Return Type:WixDataAggregate
JavaScript
Did this help?