@tpmjs/tools-rows-group-aggregate
Groups an array of objects by a specified key field and performs aggregation operations (sum, count, avg, min, max) on other fields. Useful for analyzing data by categories or creating summary statistics.
Test @tpmjs/tools-rows-group-aggregate (rowsGroupAggregateTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-rows-group-aggregatepnpm add @tpmjs/tools-rows-group-aggregateyarn add @tpmjs/tools-rows-group-aggregatebun add @tpmjs/tools-rows-group-aggregatedeno add npm:@tpmjs/tools-rows-group-aggregateimport { rowsGroupAggregateTool } from '@tpmjs/tools-rows-group-aggregate';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { rowsGroupAggregateTool } from '@tpmjs/tools-rows-group-aggregate';
const result = await generateText({
model: openai('gpt-4o'),
tools: { rowsGroupAggregateTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
rowsarrayArray of objects to group and aggregate
groupBystringThe field name to group by (supports nested fields with dot notation)
aggregatesarrayArray of aggregation operations to perform on each group. Each operation specifies a field and operation type.
Schema extracted: 1/1/2026, 8:17:46 AM
Groups rows by a key field and aggregates values using operations like sum, count, avg, min, max.
npm install @tpmjs/tools-rows-group-aggregate
import { rowsGroupAggregateTool } from '@tpmjs/tools-rows-group-aggregate'; const result = await rowsGroupAggregateTool.execute({ rows: [ { category: 'A', value: 10, price: 5.5 }, { category: 'A', value: 20, price: 6.0 }, { category: 'B', value: 30, price: 7.5 }, { category: 'B', value: 40, price: 8.0 }, ], groupBy: 'category', aggregates: [ { field: 'value', operation: 'sum' }, { field: 'value', operation: 'avg' }, { field: 'price', operation: 'max' }, { field: 'price', operation: 'min' }, ], }); console.log(result); // { // groups: [ // { // groupKey: 'A', // aggregates: { // value_sum: 30, // value_avg: 15, // price_max: 6.0, // price_min: 5.5 // }, // rowCount: 2 // }, // { // groupKey: 'B', // aggregates: { // value_sum: 70, // value_avg: 35, // price_max: 8.0, // price_min: 7.5 // }, // rowCount: 2 // } // ], // groupCount: 2 // }
user.id)sum, count, avg, min, maxMIT
Downloads/month
0
Quality Score