{"id":43004,"library":"lodash-joins","title":"lodash-joins","description":"A JavaScript library providing SQL-style join algorithms for arrays of objects, built as an extension to Lodash. Current stable version 3.1.1, released in 2022, with low release cadence. Key differentiators: supports multiple join algorithms (nested loop, hash, sorted merge) and many join types (inner, left/right outer, full outer, left/right semi, left/right anti). Ships TypeScript types. Only dependency is Lodash. Coercive key comparisons support Dates and similar types.","status":"active","version":"3.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/mtraynham/lodash-joins","tags":["javascript","joins","typescript"],"install":[{"cmd":"npm install lodash-joins","lang":"bash","label":"npm"},{"cmd":"yarn add lodash-joins","lang":"bash","label":"yarn"},{"cmd":"pnpm add lodash-joins","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"All join functions are attached to Lodash's _ object; library extends Lodash","package":"lodash","optional":false}],"imports":[{"note":"lodash-joins mutates Lodash's _ object; you must import Lodash first, then import the library for side effects.","wrong":"import { hashInnerJoin } from 'lodash-joins';","symbol":"_","correct":"import _ from 'lodash'; import 'lodash-joins';"},{"note":"All join functions are attached to Lodash's _ object, not exported as named exports.","wrong":"hashInnerJoin(left, leftKey, right, rightKey, merger);","symbol":"hashInnerJoin","correct":"_.hashInnerJoin(left, leftKey, right, rightKey, merger);"},{"note":"Same as other join functions; attached to _.","wrong":"import { nestedLoopInnerJoin } from 'lodash-joins';","symbol":"nestedLoopInnerJoin","correct":"_.nestedLoopInnerJoin(left, leftKey, right, rightKey, merger);"}],"quickstart":{"code":"const _ = require('lodash');\nrequire('lodash-joins');\n\nconst employees = [\n  { id: 1, name: 'Alice', deptId: 10 },\n  { id: 2, name: 'Bob', deptId: 20 },\n];\nconst departments = [\n  { id: 10, name: 'Engineering' },\n  { id: 30, name: 'Marketing' },\n];\n\n// Inner join on deptId\nconst result = _.hashInnerJoin(\n  employees,\n  'deptId',\n  departments,\n  'id',\n  (left, right) => ({\n    employeeName: left.name,\n    departmentName: right ? right.name : null,\n  })\n);\n\nconsole.log(result);\n// Output: [ { employeeName: 'Alice', departmentName: 'Engineering' } ]","lang":"javascript","description":"Demonstrates basic usage of hashInnerJoin with two arrays, key accessor strings, and a merger function."},"warnings":[{"fix":"Always import lodash-joins as a side-effect import: require('lodash-joins') or import 'lodash-joins'; do not attempt to destructure functions from it.","message":"Library mutates Lodash's _ object via side effects; importing for side effects is required.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use a string for simple property access, or provide a function to extract nested values.","message":"Accessor functions can be strings (property name) or functions; strings are used directly as pluck, not deep paths like 'a.b'.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update calls to sortedMerge* joins to match the new parameter order: (leftArray, leftKeyAccessor, rightArray, rightKeyAccessor, merger).","message":"In v3, the order of parameters in sorted merge join changed: leftKeyAccessor and rightKeyAccessor are now swapped to match other joins.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Do not use _.pluck; pass property name strings as accessors.","message":"_.pluck is deprecated in Lodash; accessor strings are used directly instead.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"In merger, check that left or right is not null before accessing properties; use conditional operators.","message":"Merger function receives null for left or right row in outer joins; must handle null gracefully.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2022':29 '3.1.1':26 'algorithm':12,39 'anti':57 'array':14 'built':17 'cadenc':33 'coerciv':65 'comparison':67 'current':23 'date':69 'depend':62 'differenti':35 'extens':20 'full':52 'hash':42 'inner':49 'javascript':5,73 'join':3,11,38,47,74 'key':34,66 'left/right':50,54,56 'librari':6 'lodash':2,22,64 'lodash-join':1 'loop':41 'low':31 'mani':46 'merg':44 'multipl':37 'nest':40 'object':16 'outer':51,53 'provid':7 'releas':27,32 'semi':55 'ship':58 'similar':71 'sort':43 'sql':9 'sql-style':8 'stabl':24 'style':10 'support':36,68 'type':48,60,72 'typescript':59,75 'version':25","created_at":"2026-06-05T16:57:43.067048+00:00","updated_at":"2026-06-05T16:57:43.067048+00:00","problems":[{"fix":"Ensure you require or import lodash-joins after lodash: const _ = require('lodash'); require('lodash-joins'); Then use _.hashInnerJoin(...).","cause":"lodash-joins not imported properly; functions are attached to Lodash's _ object.","error":"Uncaught TypeError: _.hashInnerJoin is not a function"},{"fix":"In the merger, check for null: (left, right) => ({ name: left ? left.name : null, ... })","cause":"Merger function called with null for right row in outer join.","error":"TypeError: Cannot read properties of undefined (reading 'name')"},{"fix":"Update to new order: (leftArray, leftKeyAccessor, rightArray, rightKeyAccessor, merger).","cause":"Parameter order changed in v3.","error":"Error: sortedMergeInnerJoin no longer supports old parameter order"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/mtraynham/lodash-joins#readme","github":"https://github.com/mtraynham/lodash-joins","docs":null,"changelog":null,"pypi":null,"npm":"lodash-joins","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}