{"id":28948984,"url":"https://github.com/forwardemail/json-sql-enhanced","last_synced_at":"2025-12-29T21:00:15.579Z","repository":{"id":298389071,"uuid":"999838826","full_name":"forwardemail/json-sql-enhanced","owner":"forwardemail","description":"A powerful, modern fork of json-sql with comprehensive MongoDB operators and multi-dialect support","archived":false,"fork":false,"pushed_at":"2025-11-27T21:06:36.000Z","size":93,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-30T11:53:04.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/forwardemail.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-10T21:42:28.000Z","updated_at":"2025-11-27T21:06:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"f1cc1b24-4dde-4747-8e3c-eafedfeabf57","html_url":"https://github.com/forwardemail/json-sql-enhanced","commit_stats":null,"previous_names":["forwardemail/json-sql-enhanced"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/forwardemail/json-sql-enhanced","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forwardemail%2Fjson-sql-enhanced","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forwardemail%2Fjson-sql-enhanced/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forwardemail%2Fjson-sql-enhanced/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forwardemail%2Fjson-sql-enhanced/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/forwardemail","download_url":"https://codeload.github.com/forwardemail/json-sql-enhanced/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forwardemail%2Fjson-sql-enhanced/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28121153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-29T02:00:07.021Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-23T11:37:23.843Z","updated_at":"2025-12-29T21:00:15.574Z","avatar_url":"https://github.com/forwardemail.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON-SQL Enhanced - Modern Edition\n\n**A powerful, modern fork of json-sql with comprehensive MongoDB operators and multi-dialect support**\n\n[![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![build status](https://github.com/forwardemail/json-sql-enhanced/actions/workflows/ci.yml/badge.svg)](https://github.com/forwardemail/json-sql-enhanced/actions/workflows/ci.yml)\n[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![license](https://img.shields.io/github/license/forwardemail/json-sql-enhanced.svg)](LICENSE)\n\n## 🚀 What's New in This Fork\n\nThis is a comprehensive modernization and enhancement of the original [json-sql](https://github.com/2do2go/json-sql) library, featuring:\n\n### ✨ **Modern JavaScript \u0026 Tooling**\n\n- **Node.js 18+ support** with modern ES features\n- **Zero dependencies** - removed underscore.js, using native JavaScript\n- **Modern development workflow** with Prettier, XO, ESLint\n- **Ava test framework** replacing Mocha/Chai\n- **Git hooks** with Husky, lint-staged, and commitlint\n- **2-space indentation** throughout codebase\n\n### 🔥 **Enhanced MongoDB Operators**\n\n- **`$regex`** with `$options` support for case-insensitive pattern matching\n- **`$size`** for array length queries\n- **`$exists`** for field existence checks\n- **`$elemMatch`** for complex array element matching\n- **Field-level `$not`** for negation\n- **Complex `$and`/`$or`** with nested logical operations\n\n### 🗄️ **Multi-Dialect Optimization**\n\n- **PostgreSQL**: Native `~`, `~*` operators, ILIKE, JSONB functions\n- **MySQL**: REGEXP operator, JSON functions, case-insensitive handling\n- **SQL Server**: Pattern approximation, OPENJSON for arrays\n- **SQLite**: Progressive fallback (LIKE → GLOB → REGEXP), JSON1 support\n\n### 🐛 **GitHub Issues Fixed**\n\n- **#57**: Empty objects `{}` convert to `NULL`\n- **#56**: Buffer support with automatic hex conversion\n- **#55**: BSON ObjectId support with `toHexString()` method\n\n## 📦 Installation\n\n```bash\nnpm install json-sql-enhanced\n```\n\n## 🎯 Quick Start\n\n```javascript\nconst jsonSql = require('json-sql-enhanced')();\n\n// Basic query\nconst result = jsonSql.build({\n  type: 'select',\n  table: 'users',\n  condition: {\n    name: { $regex: 'John', $options: 'i' },\n    age: { $gt: 18 },\n    emails: { $size: { $gt: 0 } },\n  },\n});\n\nconsole.log(result.query);\n// Output: select * from \"users\" where \"name\" ILIKE $p1 and \"age\" \u003e $p2 and JSON_LENGTH(\"emails\") \u003e $p3\n\nconsole.log(result.values);\n// Output: { p1: '%John%', p2: 18, p3: 0 }\n```\n\n## 🔍 MongoDB Operators\n\n### **$regex with $options**\n\n```javascript\n// Case-insensitive pattern matching\n{ fullName: { $regex: 'John', $options: 'i' } }\n// → PostgreSQL: \"fullName\" ILIKE '%John%'\n// → MySQL: LOWER(\"fullName\") LIKE LOWER('%John%')\n// → SQLite: \"fullName\" LIKE '%John%' COLLATE NOCASE\n\n// Pattern optimization\n{ name: { $regex: '^John' } }     // → \"name\" LIKE 'John%'\n{ name: { $regex: 'Smith$' } }    // → \"name\" LIKE '%Smith'\n{ name: { $regex: '^John$' } }    // → \"name\" = 'John'\n```\n\n### **$elemMatch for Arrays**\n\n```javascript\n// Complex array element matching\n{\n  emails: {\n    $elemMatch: {\n      value: { $regex: '@company\\\\.com$', $options: 'i' },\n      type: 'work'\n    }\n  }\n}\n// → PostgreSQL: EXISTS(SELECT 1 FROM jsonb_array_elements(\"emails\") elem WHERE ...)\n// → MySQL: JSON_SEARCH(\"emails\", 'one', '%@company.com%') IS NOT NULL\n// → SQLite: EXISTS(SELECT 1 FROM json_each(\"emails\") WHERE ...)\n```\n\n### **$size for Array Length**\n\n```javascript\n{\n  tags: {\n    $size: 3;\n  }\n} // → JSON_LENGTH(\"tags\") = 3\n{\n  emails: {\n    $size: {\n      $gt: 0;\n    }\n  }\n} // → JSON_LENGTH(\"emails\") \u003e 0\n```\n\n### **$exists for Field Presence**\n\n```javascript\n{\n  email: {\n    $exists: true;\n  }\n} // → \"email\" IS NOT NULL\n{\n  phone: {\n    $exists: false;\n  }\n} // → \"phone\" IS NULL\n```\n\n### **Complex Logical Operations**\n\n```javascript\n{\n  $and: [\n    { age: { $gte: 18 } },\n    {\n      $or: [{ status: 'active' }, { emails: { $size: { $gt: 0 } } }],\n    },\n  ];\n}\n```\n\n## 🌐 Multi-Dialect Support\n\n```javascript\n// PostgreSQL optimizations\nconst pgSql = require('json-sql-enhanced')({ dialect: 'postgresql' });\n\n// MySQL optimizations\nconst mysqlSql = require('json-sql-enhanced')({ dialect: 'mysql' });\n\n// SQLite optimizations\nconst sqliteSql = require('json-sql-enhanced')({ dialect: 'sqlite' });\n\n// SQL Server support\nconst mssqlSql = require('json-sql-enhanced')({ dialect: 'mssql' });\n```\n\n## 🔄 Migration from Original json-sql\n\nThis fork is **100% backward compatible**. Simply replace your import:\n\n```javascript\n// Before\nconst jsonSql = require('json-sql')();\n\n// After\nconst jsonSql = require('json-sql-enhanced')();\n\n// All existing code works unchanged!\n```\n\n## 🧪 Example Queries\n\nAll these complex MongoDB-style queries are supported:\n\n```javascript\n// Case-insensitive regex with options\n{ fullName: { $regex: 'John', $options: 'i' } }\n\n// Array element matching with nested conditions\n{\n  emails: {\n    $elemMatch: {\n      value: { $regex: 'john@example\\\\.com', $options: 'i' }\n    }\n  }\n}\n\n// Complex logical operations\n{\n  $or: [\n    { emails: { $exists: false } },\n    { emails: { $size: 0 } }\n  ]\n}\n\n// Negation with nested operators\n{\n  $not: {\n    emails: {\n      $elemMatch: { type: { $regex: '^WORK$', $options: 'i' } }\n    }\n  }\n}\n\n// Multiple conditions with $and\n{\n  $and: [\n    {\n      emails: {\n        $elemMatch: { value: { $regex: '@example\\\\.com', $options: 'i' } }\n      }\n    },\n    {\n      emails: { $elemMatch: { value: { $regex: '^john', $options: 'i' } } }\n    }\n  ]\n}\n```\n\n## 🛠️ Development\n\n```bash\n# Install dependencies\nnpm install\n\n# Run tests\nnpm test\n\n# Format code\nnpm run format\n\n# Lint code\nnpm run lint\n\n# Fix linting issues\nnpm run lint:fix\n```\n\n## 📋 Requirements\n\n- **Node.js 18+**\n- **Modern JavaScript environment**\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'feat: add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📄 License\n\nMIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- Original [json-sql](https://github.com/2do2go/json-sql) library by 2do2go\n- MongoDB query syntax inspiration\n- Modern JavaScript community for best practices\n\n## 📚 Documentation\n\nFor detailed documentation, examples, and API reference, see the [docs](./docs) directory:\n\n- [MongoDB Operators Guide](./docs/MONGODB-OPERATORS.md)\n- [Multi-Dialect Support](./docs/README.md)\n- [GitHub Issues Fixed](./docs/GITHUB-ISSUES.md)\n- [Changelog](./docs/CHANGELOG.md)\n\n---\n\n**Made with ❤️ for the JavaScript community**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforwardemail%2Fjson-sql-enhanced","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforwardemail%2Fjson-sql-enhanced","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforwardemail%2Fjson-sql-enhanced/lists"}