@tpmjs/tools-rows-join
Joins two arrays of objects by matching key fields. Supports inner join (only matches), left join (all left + matches), right join (all right + matches), and full outer join (all from both). Fields are prefixed with left_ and right_ to avoid collisions.
Test @tpmjs/tools-rows-join (rowsJoinTool) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-rows-joinpnpm add @tpmjs/tools-rows-joinyarn add @tpmjs/tools-rows-joinbun add @tpmjs/tools-rows-joindeno add npm:@tpmjs/tools-rows-joinimport { rowsJoinTool } from '@tpmjs/tools-rows-join';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { rowsJoinTool } from '@tpmjs/tools-rows-join';
const result = await generateText({
model: openai('gpt-4o'),
tools: { rowsJoinTool },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
leftarrayLeft array of objects to join
rightarrayRight array of objects to join
leftKeystringField name in left array to join on (supports nested fields with dot notation)
rightKeystringField name in right array to join on (supports nested fields with dot notation)
typestringJoin type: 'inner' (only matches), 'left' (all left + matches), 'right' (all right + matches), 'full' (all from both). Defaults to 'inner'.
Schema extracted: 1/1/2026, 8:18:07 AM
Joins two arrays of objects by key fields, supporting inner, left, right, and full outer joins.
npm install @tpmjs/tools-rows-join
import { rowsJoinTool } from '@tpmjs/tools-rows-join'; const result = await rowsJoinTool.execute({ left: [ { id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }, { id: 3, name: 'Charlie' }, ], right: [ { userId: 1, score: 95 }, { userId: 2, score: 87 }, { userId: 4, score: 92 }, ], leftKey: 'id', rightKey: 'userId', type: 'left', }); console.log(result); // { // rows: [ // { joinKey: 1, left_id: 1, left_name: 'Alice', right_userId: 1, right_score: 95 }, // { joinKey: 2, left_id: 2, left_name: 'Bob', right_userId: 2, right_score: 87 }, // { joinKey: 3, left_id: 3, left_name: 'Charlie' } // ], // matchedCount: 2, // unmatchedLeft: 1, // unmatchedRight: 0 // }
'inner'
'inner': Only return rows that match in both arrays'left': Return all rows from left array, with matches from right'right': Return all rows from right array, with matches from left'full': Return all rows from both arraysThe joined rows have fields prefixed to avoid collisions:
left_right_joinKey field contains the matched key valueconst result = await rowsJoinTool.execute({ left: [{ id: 1 }, { id: 2 }], right: [{ id: 1 }], leftKey: 'id', rightKey: 'id', type: 'inner', }); // Returns only the row with id: 1
const result = await rowsJoinTool.execute({ left: [{ id: 1 }, { id: 2 }], right: [{ id: 2 }, { id: 3 }], leftKey: 'id', rightKey: 'id', type: 'full', }); // Returns rows for id: 1, 2, and 3
MIT
Downloads/month
0
Quality Score