aggregates

Contains the result of applied DataSource aggregate functions.

If aggregation is configured, this property will contain a list of dictionaries having the following properties:
- field - the path to the property of each item, included in the calculation
- aggregate - the type of aggregate function applied
- value - the result of the aggregate function

var dataSource = new shield.DataSource({
    data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    aggregate: [
        { field: "", aggregate: "count" },
        { field: "", aggregate: "min" },
        { field: "", aggregate: "max" },
        { field: "", aggregate: "average" },
        { field: "", aggregate: "sum" },
        { field: "", aggregate: function(data, aggregate) { return 100; } }
    ]
});

dataSource.read().then(function() {
    console.log(dataSource.aggregates[0].value);
    // prints 10

    console.log(dataSource.aggregates[1].value);
    // prints 1

    console.log(dataSource.aggregates[2].value);
    // prints 10

    console.log(dataSource.aggregates[3].value);
    // prints 5.5

    console.log(dataSource.aggregates[4].value);
    // prints 55

    console.log(dataSource.aggregates[5].value);
    // prints 100
});