@tpmjs/tools-rows-filter
Filter an array of objects by a predicate with support for field comparisons
operator must be one of: eq, ne, gt, lt, gte, lte, contains
Last checked: 2/27/2026, 4:17:42 AM
Test @tpmjs/tools-rows-filter (rowsFilterTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-rows-filterpnpm add @tpmjs/tools-rows-filteryarn add @tpmjs/tools-rows-filterbun add @tpmjs/tools-rows-filterdeno add npm:@tpmjs/tools-rows-filterimport { rowsFilterTool } from '@tpmjs/tools-rows-filter';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { rowsFilterTool } from '@tpmjs/tools-rows-filter';
const result = await generateText({
model: openai('gpt-4o'),
tools: { rowsFilterTool },
prompt: 'Your prompt here...',
});
console.log(result.text);(rows: Record<string, unknown>[], field: string, value: { }, operator: string) => Promise<unknown>Available configuration options
rowsarrayArray of objects to filter
fieldstringField name to filter on
operatorstringComparison operator: eq, ne, gt, lt, gte, lte, contains
valueanyValue to compare against
Schema extracted: 2/27/2026, 4:17:41 AM
Filter an array of objects by comparing field values against target values using various comparison operators.
user.name)npm install @tpmjs/tools-rows-filter ai
import { rowsFilterTool } from '@tpmjs/tools-rows-filter'; import { generateText } from 'ai'; const result = await generateText({ model: yourModel, tools: { rowsFilter: rowsFilterTool, }, prompt: 'Filter the users to show only those over 25 years old', });
rows (array, required): Array of objects to filterfield (string, required): Field name to filter on (supports dot notation)operator (string, required): Comparison operator to use
eq: equalsne: not equalsgt: greater than (numbers/strings)lt: less than (numbers/strings)gte: greater than or equal (numbers/strings)lte: less than or equal (numbers/strings)contains: substring match (case-insensitive) or array containsvalue (any, required): Value to compare against{ rows: Record<string, unknown>[], // Filtered array matchCount: number, // Number of matching rows totalCount: number // Total number of input rows }
const data = [ { name: 'Alice', age: 30 }, { name: 'Bob', age: 25 }, { name: 'Charlie', age: 35 }, ]; // Returns: { rows: [Alice, Charlie], matchCount: 2, totalCount: 3 } await rowsFilterTool.execute({ rows: data, field: 'age', operator: 'gte', value: 30, });
const products = [ { name: 'Laptop', category: 'electronics' }, { name: 'Desk', category: 'furniture' }, { name: 'Phone', category: 'electronics' }, ]; // Returns: { rows: [Laptop, Phone], matchCount: 2, totalCount: 3 } await rowsFilterTool.execute({ rows: products, field: 'category', operator: 'eq', value: 'electronics', });
const users = [ { email: 'alice@example.com' }, { email: 'bob@gmail.com' }, { email: 'charlie@example.com' }, ]; // Returns: { rows: [alice, charlie], matchCount: 2, totalCount: 3 } await rowsFilterTool.execute({ rows: users, field: 'email', operator: 'contains', value: 'example', });
const orders = [ { id: 1, customer: { name: 'Alice', tier: 'premium' } }, { id: 2, customer: { name: 'Bob', tier: 'basic' } }, { id: 3, customer: { name: 'Charlie', tier: 'premium' } }, ]; // Returns: { rows: [order1, order3], matchCount: 2, totalCount: 3 } await rowsFilterTool.execute({ rows: orders, field: 'customer.tier', operator: 'eq', value: 'premium', });
MIT
Downloads/month
17
GitHub Stars
0
Quality Score