run( )


Developer Preview

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

Runs the aggregation and returns the results.

The run() method returns a Promise that resolves to the results found by the aggregation and some information about the results.

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

Method Declaration
Copy
function run(options: WixDataAggregateOptions): Promise<WixDataResult>;
Method Parameters
optionsWixDataAggregateOptions

Options to use when running an aggregation.

Returns
Return Type:Promise<WixDataResult>
JavaScript
import { items } from "@wix/data"; async function aggregateItems() { const filter = items.filter().eq("year", 2010); const having = items.filter().gt("maxPopulation", 1000000); const results = await items .aggregate("PopulationData") .filter(filter) .group("state") .max("population", "maxPopulation") .having(having) .descending("maxPopulation") .skip(5) .limit(3) .run(); if (results.items.length > 0) { const items = results.items; const numItems = results.length; const hasNext = results.hasNext(); } else { // handle case where no matching items found } }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?