A utility that converts flat MySQL join query results into nested JavaScript objects. Version 0.0.3 (latest as of 2015) is stable with no recent updates. It works with the mysql npm package by requiring nestTables: true and providing a nesting options array to define table relationships. Differentiators: lightweight, explicit foreign key mapping, and simple API. No TypeScript types, ESM support, or active maintenance.
npm install node-mysql-nestingNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to use node-mysql-nesting with mysql package: query with nestTables:true, define nesting options, and convert flat rows to nested objects.
List nestingOptions in the same order as tables in the FROM and JOIN clauses.
Use mysql2 and adapt the callback pattern or use promise-based wrappers.
Consider alternatives like 'mysql2' with 'nestTables' built-in or manual mapping.
Always include nestTables: true in the mysql query options object.
Order tables so that parent tables appear before child tables.
Use const func = require('node-mysql-nesting'); then func.convertToNested(rows, options);Ensure nestingOptions entries match the exact order of tables in the SELECT statement and all tables are included.
Check the actual column names in your database and update fkeys accordingly.