A modern fork of json-sql that converts MongoDB-style query objects into SQL queries with support for PostgreSQL, MySQL, SQLite, and MSSQL dialects. Version 3.0.0 is the current stable release with zero dependencies, active development on GitHub, and comprehensive support for operators like $regex, $size, $exists, $elemMatch, and nested logical operations. It differentiates from alternatives by providing dialect-optimized SQL generation, TypeScript type definitions, and a leaner API compared to larger ORMs.
npm install json-sql-enhancedNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates factory import, building a SELECT query with $regex, $gt, and $size operators, and extracting the generated SQL and values.
Change from const jsonSql = require('json-sql'); to const jsonSql = require('json-sql-enhanced')();Update Node.js to version 18 or higher, or use v2.x for older Node versions.
If you relied on underscore methods, polyfill them or use native alternatives.
When using the result.values object, reference keys like 'p1', 'p2' instead of named placeholders.
Check the dialect's allowed flags (e.g., 'i' for case-insensitive) before passing $options.
If you used {} to mean 'no condition', use undefined or remove the key instead.Let the library handle conversion; do not call .toString('hex') beforehand.Use const jsonSql = require('json-sql-enhanced')(); (notice the invocation parentheses).Upgrade Node.js to version 18 or higher.
Ensure you call the factory: const instance = require('json-sql-enhanced')(); then instance.build().Access values as an object, e.g., result.values.p1, not result.values[0].