Value

// Add a chart to the Dashboard page
agent.addChart('monthlyRecuringRevenue', async (context, resultBuilder) => {
// Request the sum of the "amount" field of all the records in the "payments" collection
const aggregation = { operation: 'Sum', field: 'amount' };
const filter = { conditionTree: { field: 'status', operator: 'equal', value: 'paid' } };
const rows = await context.dataSource.getCollection('payments').aggregate(filter, aggregation);
// Return the result to the chart
return resultBuilder.value(rows[0].value);
});
Last updated