{"id":37017040,"url":"https://github.com/vincentrussell/sql-to-mongo-db-query-converter","last_synced_at":"2026-01-14T01:57:03.048Z","repository":{"id":11611550,"uuid":"68025971","full_name":"vincentrussell/sql-to-mongo-db-query-converter","owner":"vincentrussell","description":"sql-to-mongo-db-query-converter","archived":false,"fork":false,"pushed_at":"2025-11-17T16:35:04.000Z","size":2929,"stargazers_count":313,"open_issues_count":18,"forks_count":97,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-11-17T18:06:10.003Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vincentrussell.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":"2016-09-12T16:18:49.000Z","updated_at":"2025-11-17T16:35:07.000Z","dependencies_parsed_at":"2024-04-10T03:34:43.627Z","dependency_job_id":"6e242b22-908b-4b1d-bf76-fd62ab378a4b","html_url":"https://github.com/vincentrussell/sql-to-mongo-db-query-converter","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/vincentrussell/sql-to-mongo-db-query-converter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentrussell%2Fsql-to-mongo-db-query-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentrussell%2Fsql-to-mongo-db-query-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentrussell%2Fsql-to-mongo-db-query-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentrussell%2Fsql-to-mongo-db-query-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vincentrussell","download_url":"https://codeload.github.com/vincentrussell/sql-to-mongo-db-query-converter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentrussell%2Fsql-to-mongo-db-query-converter/sbom","scorecard":{"id":922274,"data":{"date":"2025-08-11","repo":{"name":"github.com/vincentrussell/sql-to-mongo-db-query-converter","commit":"508ce33c91ef89c37773ef2cb3c7d126901c2036"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 1/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/vincentrussell/sql-to-mongo-db-query-converter/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/vincentrussell/sql-to-mongo-db-query-converter/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/vincentrussell/sql-to-mongo-db-query-converter/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/vincentrussell/sql-to-mongo-db-query-converter/main.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-78wr-2p64-hpwj","Warn: Project is vulnerable to: GHSA-j288-q9x7-2f5v"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-25T05:26:24.632Z","repository_id":11611550,"created_at":"2025-08-25T05:26:24.632Z","updated_at":"2025-08-25T05:26:24.632Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-14T01:57:02.407Z","updated_at":"2026-01-14T01:57:03.040Z","avatar_url":"https://github.com/vincentrussell.png","language":"Java","funding_links":[],"categories":["Tools"],"sub_categories":["Development"],"readme":"# sql-to-mongo-db-query-converter [![Maven Central](https://img.shields.io/maven-central/v/com.github.vincentrussell/sql-to-mongo-db-query-converter.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.vincentrussell%22%20AND%20a:%22sql-to-mongo-db-query-converter%22) [![Build Status](https://travis-ci.org/vincentrussell/sql-to-mongo-db-query-converter.svg?branch=master)](https://travis-ci.org/vincentrussell/sql-to-mongo-db-query-converter)\n\nsql-to-mongo-db-query-converter helps you build quieres for MongoDb based on Queries provided in SQL.   \n\n## Maven\n\nAdd a dependency to `com.github.vincentrussell:sql-to-mongo-db-query-converter`. \n\n```\n\u003cdependency\u003e\n   \u003cgroupId\u003ecom.github.vincentrussell\u003c/groupId\u003e\n   \u003cartifactId\u003esql-to-mongo-db-query-converter\u003c/artifactId\u003e\n   \u003cversion\u003e1.23\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Requirements\n- JDK 1.8 or higher\n\n## Running it from Java\n\n```\nQueryConverter queryConverter = new QueryConverter.Builder().sqlString(\"select column1 from my_table where value NOT IN (\"theValue1\",\"theValue2\",\"theValue3\")\").build();\nMongoDBQueryHolder mongoDBQueryHolder = queryConverter.getMongoQuery();\nString collection = mongoDBQueryHolder.getCollection();\nDocument query = mongoDBQueryHolder.getQuery();\nDocument projection = mongoDBQueryHolder.getProjection();\nDocument sort = mongoDBQueryHolder.getSort();\n```\n\n## Running it as a standalone jar\n\n```\njava -jar sql-to-mongo-db-query-converter-1.23-standalone.jar -s sql.file -d destination.json\n```\n### Options\n\n```\nusage: com.github.vincentrussell.query.mongodb.sql.converter.Main [-s\n       \u003carg\u003e | -sql \u003carg\u003e | -i]   [-d \u003carg\u003e | -h \u003carg\u003e]  [-db \u003carg\u003e] [-a\n       \u003carg\u003e] [-u \u003carg\u003e] [-p \u003carg\u003e] [-b \u003carg\u003e]\n -s,--sourceFile \u003carg\u003e        the source file.\n -sql,--sql \u003carg\u003e             the select statement\n -i,--interactiveMode         interactive mode\n -l,--loopMode                interactive loopMode mode\n -d,--destinationFile \u003carg\u003e   the destination file.  Defaults to\n                              System.out\n -h,--host \u003carg\u003e              hosts and ports in the following format\n                              (host:port) default port is 27017\n -db,--database \u003carg\u003e         mongo database\n -a,--auth database \u003carg\u003e     auth mongo database\n -u,--username \u003carg\u003e          usename\n -p,--password \u003carg\u003e          password\n -b,--batchSize \u003carg\u003e         batch size for query results\n```\n\n### Special Aggregation-specific System Properties\n\n```\n-DaggregationAllowDiskUse\nEnables writing to temporary files. When set to true, aggregation operations can write data to the _tmp subdirectory in the dbPath directory.\n\n-DaggregationBatchSize\nTo specify an initial batch size for the cursor\n```\n\n## Interactive mode\n\n```\njava -jar target/sql-to-mongo-db-query-converter-1.18-standalone.jar -i\nEnter input sql:\n\n\nselect object.key1, object2.key3, object1.key4 from my_collection where object.key2 = 34 AND object2.key4 \u003e 5\n\n\n******Result:*********\n\ndb.my_collection.find({\n  \"$and\": [\n    {\n      \"key2\": {\n        \"$numberLong\": \"34\"\n      }\n    },\n    {\n      \"object2.key4\": {\n        \"$gt\": {\n          \"$numberLong\": \"5\"\n        }\n      }\n    }\n  ]\n} , {\n  \"_id\": 0,\n  \"object.key1\": 1,\n  \"object2.key3\": 1,\n  \"object1.key4\": 1\n})\n\n```\n\n##Available options\n\n###Dates\n\n```\nselect * from my_table where date(column,'YYYY-MM-DD') \u003e= '2016-12-12'\n\n\n******Result:*********\n\ndb.my_table.find({\n  \"column\": {\n    \"$gte\": {\n      \"$date\": 1452556800000\n    }\n  }\n})\n```\n\n###Natural Language Dates\n\n```\nselect * from my_table where date(column,'natural') \u003e= '5000 days ago'\n\n\n******Result:*********\n\ndb.my_table.find({\n  \"column\": {\n    \"$gte\": {\n      \"$date\": 1041700019654\n    }\n  }\n})\n```\n\n###Regex\n\n```\nselect * from my_table where regexMatch(column,'^[ae\"gaf]+$')\n\n\n******Result:*********\n\ndb.my_table.find({\n  \"column\": {\n    \"$regex\": \"^[ae\\\"gaf]+$\"\n  }\n})\n```\n\n###NOT Regex match\n\n```\nselect * from my_table where notRegexMatch(column,'^[ae\"gaf]+$')\n\n\n******Result:*********\n\ndb.my_table.find({\n  \"column\": {\n    \"$not\": /^[ae\\\"gaf]+$/\n  }\n})\n```\n\n###Distinct\n\n```\nselect distinct column1 from my_table where value IS NULL\n\n\n******Result:*********\n\ndb.my_table.distinct(\"column1\" , {\n  \"value\": {\n    \"$exists\": false\n  }\n})\n```\n\n###Like\n\n```\nselect * from my_table where value LIKE 'start%'\n\n\n******Result:*********\n\ndb.my_table.find({\n  \"value\": {\n    \"$regex\": \"^start.*$\"\n  }\n})\n```\n\n###Like\n\n```\nselect * from my_table where value NOT LIKE 'start%'\n\n\n******Result:*********\n\ndb.my_table.find({\n  \"value\": {\n    \"$not\": /^start.*$/\n  }\n})\n```\n\n###In\n\n```\nselect column1 from my_table where value IN (\"theValue1\",\"theValue2\",\"theValue3\")\n\n\n******Result:*********\n\ndb.my_table.find({ \n\t\"value\" : { \n\t\t\"$in\" : [\"theValue1\",\"theValue2\", \"theValue3\"] \n\t\t}\n})\n```\n\n###Not In\n\n```\nselect column1 from my_table where value NOT IN (\"theValue1\",\"theValue2\",\"theValue3\")\n\n\n******Result:*********\n\ndb.my_table.find({ \n\t\"value\" : { \n\t\t\"$nin\" : [\"theValue1\",\"theValue2\", \"theValue3\"] \n\t\t}\n})\n```\n\n###Is True\n\n```\nselect column1 from my_table where column = true\n\n\n******Result:*********\n\ndb.my_table.find({ \n\t\"column\" : true\n})\n```\n\n###Is False\n\n```\nselect column1 from my_table where column = false\n\n\n******Result:*********\n\ndb.my_table.find({ \n\t\"column\" : false\n})\n```\n\n###Not True\n\n```\nselect column1 from my_table where NOT column\n\n\n******Result:*********\n\ndb.my_table.find({ \n\t\"value\" : {$ne: true}\n})\n```\n\n\n###ObjectId Support\n\n```\nselect column1 from  where OBJECTID('_id') IN ('53102b43bf1044ed8b0ba36b', '54651022bffebc03098b4568')\n\n******Result:*********\n\ndb.my_table.find({ \n\t\"_id\" : {$in: [{$oid: \"53102b43bf1044ed8b0ba36b\"},{$oid: \"54651022bffebc03098b4568\"}]}\n})\n```\n\n```\nselect column1 from  where OBJECTID('_id') = '53102b43bf1044ed8b0ba36b'\n\n******Result:*********\n\ndb.my_table.find({ \n\t\"_id\" : {$oid: \"53102b43bf1044ed8b0ba36b\"}\n})\n```\n\n###Delete\n\n```\ndelete from my_table where value IN (\"theValue1\",\"theValue2\",\"theValue3\")\n\n\n******Result:*********\n\n3 (number or records deleted)\n```\n\n###Update\n\n```\nUPDATE my_table SET name = 'John Doe', city= 'Melphis' WHERE customerID = 1;\n\n******Result:*********\n\n1 (number or records updated)\n```\n\n###Group By (Aggregation)\n\n```\nselect borough, cuisine, count(*) from my_collection WHERE borough LIKE 'Queens%' GROUP BY borough, cuisine ORDER BY count(*) DESC;\n\n\n******Mongo Query:*********\n\ndb.my_collection.aggregate([{\n  \"$match\": {\n    \"borough\": {\n      \"$regex\": \"^Queens.*$\"\n    }\n  }\n},{\n  \"$group\": {\n    \"_id\": {\n      \"borough\": \"$borough\",\n      \"cuisine\": \"$cuisine\"\n    },\n    \"count\": {\n      \"$sum\": 1\n    }\n  }\n},{\n  \"$sort\": {\n    \"count\": -1\n  }\n},{\n  \"$project\": {\n    \"borough\": \"$_id.borough\",\n    \"cuisine\": \"$_id.cuisine\",\n    \"count\": 1,\n    \"_id\": 0\n  }\n}])\n```\n\n###Having clause with aggregation\n\n```\nselect Restaurant.cuisine, count(*) from Restaurants group by Restaurant.cuisine having count(*) \u003e 3;\n\n\n******Mongo Query:*********\n\ndb.Restaurants.aggregate([\n                           {\n                             \"$group\": {\n                               \"_id\": \"$Restaurant.cuisine\",\n                               \"count\": {\n                                 \"$sum\": 1\n                               }\n                             }\n                           },\n                           {\n                             \"$match\": {\n                               \"$expr\": {\n                                 \"$gt\": [\n                                   \"$count\",\n                                   3\n                                 ]\n                               }\n                             }\n                           },\n                           {\n                             \"$project\": {\n                               \"Restaurant.cuisine\": \"$_id\",\n                               \"count\": 1,\n                               \"_id\": 0\n                             }\n                           }\n                         ])\n```\n\n###Count without GROUP BY\n```\nselect count(*) as c from table\n\n******Mongo Query:*********\ndb.table.aggregate([{ \"$group\": { \"_id\": {}, \"c\": { \"$sum\": 1 } } },{ \"$project\": { \"c\": 1, \"_id\": 0 } }])\n```\n\n###Avg without GROUP BY\n\n```\nselect avg(field) as avg from table\n\n******Mongo Query:*********\ndb.table.aggregate([{ \"$group\": { \"_id\": {}, \"avg\": { \"$avg\": \"$field\" } } },{ \"$project\": { \"avg\": 1, \"_id\": 0 } }])\n```\n\n###Joins\n\n```\nselect t1.column1, t2.column2 from my_table as t1 inner join my_table2 as t2 on t1.column = t2.column\n\n\n******Result:*********\n\ndb.my_table.aggregate([\n                   {\n                     \"$match\": {}\n                   },\n                   {\n                     \"$lookup\": {\n                       \"from\": \"my_table2\",\n                       \"let\": {\n                         \"column\": \"$column\"\n                       },\n                       \"pipeline\": [\n                         {\n                           \"$match\": {\n                             \"$expr\": {\n                               \"$eq\": [\n                                 \"$$column\",\n                                 \"$column\"\n                               ]\n                             }\n                           }\n                         }\n                       ],\n                       \"as\": \"t2\"\n                     }\n                   },\n                   {\n                     \"$unwind\": {\n                       \"path\": \"$t2\",\n                       \"preserveNullAndEmptyArrays\": false\n                     }\n                   },\n                   {\n                     \"$project\": {\n                       \"_id\": 0,\n                       \"column1\": 1,\n                       \"t2.column2\": 1\n                     }\n                   }\n                 ])\n\n\nor\n\nselect t1.Column1, t2.Column2 from my_table as t1 inner join my_table2 as t2 on t1.nested1.Column = t2.nested2.Column inner join my_table3 as t3 on t1.nested1.Column = t3.nested3.Column where t1.nested1.whereColumn1 = \"whereValue1\" and t2.nested2.whereColumn2 = \"whereValue2\" and t3.nested3.whereColumn3 = \"whereValue3\"\n\n\n******Result:*********\n\ndb.my_table.aggregate([\n                        {\n                          \"$match\": {\n                            \"nested1.whereColumn1\": \"whereValue1\"\n                          }\n                        },\n                        {\n                          \"$lookup\": {\n                            \"from\": \"my_table2\",\n                            \"let\": {\n                              \"nested1_column\": \"$nested1.Column\"\n                            },\n                            \"pipeline\": [\n                              {\n                                \"$match\": {\n                                  \"$and\": [\n                                    {\n                                      \"$expr\": {\n                                        \"$eq\": [\n                                          \"$$nested1_column\",\n                                          \"$nested2.Column\"\n                                        ]\n                                      }\n                                    },\n                                    {\n                                      \"nested2.whereColumn2\": \"whereValue2\"\n                                    }\n                                  ]\n                                }\n                              }\n                            ],\n                            \"as\": \"t2\"\n                          }\n                        },\n                        {\n                          \"$unwind\": {\n                            \"path\": \"$t2\",\n                            \"preserveNullAndEmptyArrays\": false\n                          }\n                        },\n                        {\n                          \"$lookup\": {\n                            \"from\": \"my_table3\",\n                            \"let\": {\n                              \"nested1_column\": \"$nested1.Column\"\n                            },\n                            \"pipeline\": [\n                              {\n                                \"$match\": {\n                                  \"$and\": [\n                                    {\n                                      \"$expr\": {\n                                        \"$eq\": [\n                                          \"$$nested1_column\",\n                                          \"$nested3.Column\"\n                                        ]\n                                      }\n                                    },\n                                    {\n                                      \"nested3.whereColumn3\": \"whereValue3\"\n                                    }\n                                  ]\n                                }\n                              }\n                            ],\n                            \"as\": \"t3\"\n                          }\n                        },\n                        {\n                          \"$unwind\": {\n                            \"path\": \"$t3\",\n                            \"preserveNullAndEmptyArrays\": false\n                          }\n                        },\n                        {\n                          \"$project\": {\n                            \"_id\": 0,\n                            \"c1\": \"$Column1\",\n                            \"c2\": \"$t2.Column2\",\n                            \"c3\": \"$t3.Column3\"\n                          }\n                        }\n                      ])\n\n\n```\n\n\n###Alias\n\n```\nselect object.key1 as key1, object2.key3 as key3, object1.key4 as key4 from my_collection where object.key2 = 34 AND object2.key4 \u003e 5;\n\n\n******Mongo Query:*********\n\ndb.Restaurants.aggregate([{\n  \"$match\": {\n    \"$and\": [\n      {\n        \"Restaurant.cuisine\": \"American\"\n      },\n      {\n        \"Restaurant.borough\": {\n          \"$gt\": \"N\"\n        }\n      }\n    ]\n  }\n},{\n  \"$project\": {\n    \"_id\": 0,\n    \"key1\": \"$Restaurant.borough\",\n    \"key3\": \"$Restaurant.cuisine\",\n    \"key4\": \"$Restaurant.address.zipcode\"\n  }\n}])\n```\n\n###Alias Group By (Aggregation)\n\n```\nselect borough as b, cuisine as c, count(*) as co from my_collection WHERE borough LIKE 'Queens%' GROUP BY borough, cuisine ORDER BY count(*) DESC;\n\n\n******Mongo Query:*********\n\ndb.my_collection.aggregate([{\n  \"$match\": {\n    \"borough\": {\n      \"$regex\": \"^Queens.*$\"\n    }\n  }\n},{\n  \"$group\": {\n    \"_id\": {\n      \"borough\": \"$borough\",\n      \"cuisine\": \"$cuisine\"\n    },\n    \"co\": {\n      \"$sum\": 1\n    }\n  }\n},{\n  \"$sort\": {\n    \"co\": -1\n  }\n},{\n  \"$project\": {\n    \"b\": \"$_id.borough\",\n    \"c\": \"$_id.cuisine\",\n    \"co\": 1,\n    \"_id\": 0\n  }\n}])\n```\n\n###Offset\n\n```\nselect * from table limit 3 offset 4\nor\nselect a, count(*) from table group by a limit 3 offset 4\n\n\n******Result:*********\n\nis equivalent to the $skip function in mongodb json query language\n```\n\n###Using column names that start with a number.  Sorround it in quotes:\n\n```\nSELECT * FROM tb_test WHERE \"3rd_column\" = 10\n```\n\n###Direct Mongo Integration\n\nYou can run the queries against an actual mongodb database and take a look at the results.  The default return batch size is 50.\n\n```\njava -jar target/sql-to-mongo-db-query-converter-1.18-SNAPSHOT-standalone.jar -i -h localhost:3086 -db local -b 5\nEnter input sql:\n\n\nselect borough, cuisine, count(*) from my_collection GROUP BY borough, cuisine ORDER BY count(*) DESC;\n\n\n******Query Results:*********\n\n[{\n\t\"borough\" : \"Manhattan\",\n\t\"cuisine\" : \"American \",\n\t\"count\" : 3205\n},{\n\t\"borough\" : \"Brooklyn\",\n\t\"cuisine\" : \"American \",\n\t\"count\" : 1273\n},{\n\t\"borough\" : \"Queens\",\n\t\"cuisine\" : \"American \",\n\t\"count\" : 1040\n},{\n\t\"borough\" : \"Brooklyn\",\n\t\"cuisine\" : \"Chinese\",\n\t\"count\" : 763\n},{\n\t\"borough\" : \"Queens\",\n\t\"cuisine\" : \"Chinese\",\n\t\"count\" : 728\n}]\n\nmore results? (y/n): y\n[{\n\t\"borough\" : \"Manhattan\",\n\t\"cuisine\" : \"Café/Coffee/Tea\",\n\t\"count\" : 680\n},{\n\t\"borough\" : \"Manhattan\",\n\t\"cuisine\" : \"Italian\",\n\t\"count\" : 621\n},{\n\t\"borough\" : \"Manhattan\",\n\t\"cuisine\" : \"Chinese\",\n\t\"count\" : 510\n},{\n\t\"borough\" : \"Manhattan\",\n\t\"cuisine\" : \"Japanese\",\n\t\"count\" : 438\n},{\n\t\"borough\" : \"Bronx\",\n\t\"cuisine\" : \"American \",\n\t\"count\" : 411\n}]\n\nmore results? (y/n): n\n```\n\n# Change Log\n\n## [1.23](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.23) (2025-11-17)\n\n**Bugs:**\n\n- Throw an exception if dates in queries are passed in with the following invalid formats: YYYY-MM, YYYY\n\n## [1.22](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.22) (2024-04-09)\n\n**Bugs:**\n\n- Custom functions weren't being parsed correctly\n\n\n## [1.21](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.21) (2022-03-21)\n\n**Enhancements:**\n\n- Add support for functions in the projection clause\n- Handling speciality functions with IS NULL and IS NOT NULL expression\n\n\n## [1.20](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.20) (2022-01-23)\n\n**Enhancements:**\n\n- upgrade jsqlparser to  4.3\n- Added support for update SQL statements\n\n**Bugs:**\n\n- equals operand not working with dates\n\n## [1.19](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.19) (2021-12-05)\n\n**Enhancements:**\n\n- upgrade flapdoodle to 3.0.0\n- upgrade required jdk to 1.8\n- upgrade mongoclient to 4.2.3\n- upgrade jsqlparser to  4.2\n\n**Bugs:**\n\n- alias not working properly in having clause.\n- in expressions not working with joins\n\n## [1.18](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.18) (2020-09-02)\n\n**Bugs:**\n\n- functions not handled properly with operators like $eq\n\n## [1.17](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.17) (2020-08-21)\n\n**Enhancements:**\n\n- support for BETWEEN keyword\n\n**Bugs:**\n\n- Remove use of $eq operator when not needed\n\n\n# Change Log\n\n## [1.16](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.16) (2020-08-18)\n\n**Enhancements:**\n\n- remove deprecated constructors on QueryConverter\n\n**Bugs:**\n\n- Simplifying use of $expr function\n\n## [1.15](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.15) (2020-08-15)\n\n**Enhancements:**\n\n- Added getQueryAsDocument to the QueryConverter\n- Upgraded guava to 24.1.1-jre\n- Added \"Loop mode\" with -l when running in CLI mode.\n\n**Bugs:**\n\n- Added checkstyle to build process\n- Code cleanup\n- Negative numbers are supported\n\n\n\n\n# Change Log\n\n## [1.14](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.14) (2020-07-22)\n\n**Enhancements:**\n\n- Support for Double values\n- Support for Timestamp values, i.e: {ts '2019-10-11 12:12:23.234'}\n- Support for Date values, i.e: {d '2019-10-11'}\n\n\n## [1.13](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.13) (2020-07-16)\n\n**Enhancements:**\n\n- Support for NOT LIKE queries\n- added notRegexMatch function\n\n**Bugs:**\n\n- NOT expressions with parentheses not working properly, i.e: NOT (Country = 'Albania')\n\n## [1.12](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.12) (2020-07-07)\n\n**Enhancements:**\n\n- Fix queries using IN keyword.  They were broken in 1.11\n\n## [1.11](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.11) (2020-05-22)\n\n**Enhancements:**\n\n- Support for subqueries translated to aggregation steps in a recursive way.\n- Created a builder for the QueryConverter class and depreciated the constructors for the QueryConverterClass\n- Created the ability to prove the following options to aggregation: aggregationAllowDiskUse and aggregationBatchSize\n- Support for having clause\n- Upgrading com.github.jsqlparser:jsqlparser from v1.4 to v3.1\n- Supporting group operations (avg, max, min, count, sum) without \"group by\" clause for performing a total group.\n\n# Change Log\n\n## [1.10](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.10) (2020-02-01)\n\n**Enhancements:**\n\n- Added the ability to use sql aliases that will do a mongo $project.\n- Added the ability to use offset syntax in sql to skip records\n- Added the ability to use lookup-let-pipeline strategy of mongo 3.6 and $expr for performing joins.\n- Added the ablility to join multiple tables and use them in where or project clause. In the new test class are many examples.\n\n## [1.9](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.9) (2019-04-02)\n\n**Enhancements:**\n\n- Added the capability for nested custom functions\n\n## [1.8](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.8) (2019-02-01)\n\n**Enhancements:**\n\n- Upgraded jsqlparser to version 1.4\n- Added support for deep nested queries; i.e: select * from my_table where a.b.c.d.e.key = value\n\n\n## [1.7](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.7) (2018-11-13)\n\n**Enhancements:**\n\n- Equals, Not Equals, In and Not In ObjectId query support\n- regexMatch function can be used with or without equals sign\n\n\n## [1.6](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.6) (2018-07-24)\n\n**Bugs:**\n\n- remove double quotes from column names when used in IS NULL query\n\n## [1.5](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.5) (2018-06-15)\n\n**Enhancements:**\n\n- upgrade jsqlparser to version 1.2\n- create flatter structure when chaining ORs and ANDs together\n\n\n## [1.4](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.4) (2018-03-03)\n\n**Enhancements:**\n\n- Added support NOT operator on parentheses\n- Added support for delete SQL statements\n\n## [1.3.4](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.3.4) (2018-01-27)\n\n**Enhancements:**\n\n- Added the ability to pass down custom sql functions down to mongo\n\n## [1.3.2](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.3.2) (2017-07-02)\n\n**Enhancements:**\n\n- Added the ability to support queries on boolean fields\n- UTF-8 support\n\n## [1.3.1](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.3.1) (2017-02-19)\n\n**Enhancements:**\n\n- Added the ability to have default type like Number, String, or Date\n- Added the ability to provide a type for each field like Number, String, Date\n\n## [1.3](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.3) (2017-01-31)\n\n**Enhancements:**\n\n- Added the ability to provide field types for columns passed into the query via Java API.  See QueryConverterTest for examples.\n\n## [1.2](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.2) (2016-11-30)\n\n**Bugs:**\n\n- Fix bug with IN and NOT IN expressions from not converting properly to mongo format properly\n\n\n## [1.1](https://github.com/vincentrussell/sql-to-mongo-db-query-converter/tree/sql-to-mongo-db-query-converter-1.1) (2016-10-05)\n\n**Bugs:**\n\n- Fix bug with not being able to parse like queries\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincentrussell%2Fsql-to-mongo-db-query-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvincentrussell%2Fsql-to-mongo-db-query-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincentrussell%2Fsql-to-mongo-db-query-converter/lists"}