{"id":16757033,"url":"https://github.com/guxingke/sql2mongo","last_synced_at":"2025-09-09T14:11:32.839Z","repository":{"id":101545717,"uuid":"159788037","full_name":"guxingke/sql2mongo","owner":"guxingke","description":"sql query to mongo query","archived":false,"fork":false,"pushed_at":"2020-10-13T11:05:14.000Z","size":8924,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T07:26:28.532Z","etag":null,"topics":["antlr4","cli","mongo-query","sql-query"],"latest_commit_sha":null,"homepage":"https://github.com/guxingke/sql2mongo","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guxingke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-11-30T07:53:04.000Z","updated_at":"2023-03-01T09:13:30.000Z","dependencies_parsed_at":"2023-06-11T01:30:45.088Z","dependency_job_id":null,"html_url":"https://github.com/guxingke/sql2mongo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/guxingke/sql2mongo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guxingke%2Fsql2mongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guxingke%2Fsql2mongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guxingke%2Fsql2mongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guxingke%2Fsql2mongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guxingke","download_url":"https://codeload.github.com/guxingke/sql2mongo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guxingke%2Fsql2mongo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274308383,"owners_count":25261237,"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-09-09T02:00:10.223Z","response_time":80,"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":["antlr4","cli","mongo-query","sql-query"],"created_at":"2024-10-13T03:42:44.221Z","updated_at":"2025-09-09T14:11:32.782Z","avatar_url":"https://github.com/guxingke.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sql2Mongo\nsql query convert to mongo query\n\ne.g:\n```\nselect _id,nickname from user where _id in (100002,100003) order by _id desc limit 1,1\n```\n=\u003e\n```\ndb.user.find({_id: {$in:[100002,100003]}},{_id:1, nickname:1}).sort({_id:-1}).skip(1).limit(1)\n```\n\n# PRE\n- maven 3.3+\n- jdk 1.8+\n- graalvm 1.0+\n\n# Build\n```bash\nmvn clean package\n\n./build.sh # build binary executable file named s2m.\n\n```\n\n# Install\n```bash\nbrew tap guxingke/homebrew-repo \u0026\u0026 brew install s2m\n```\n\n# Showcase\n## My Case\n\n\n```bash\n# base \n$ s2m \"select * from user where id \u003e= 1 and id = 100002\"\n#-\u003e\ndb.user.find({$and: [{id: {$gte: 1}},{id: {$eq: 100002}}]},{}).sort({_id:-1}).skip(0).limit(100)\n\n```\n\n```bash\n# shortcut.\n$ which mp\n# =\u003e\nmp () {\n  mq=`s2m \"$*\"`\n  #echo \"__mq: $mq\"\n  mongo [ip]:[port]/[db] --quiet --eval \"$mq.forEach(printjson)\"\n}\n\n# base query\n$ mp \"select _id,nickname from user where _id in (100002,100003) order by _id desc limit 10\"\n# =\u003e\n{ \"_id\" : NumberLong(100003), \"nickname\" : \"就是辣么帅2323\" }\n{ \"_id\" : NumberLong(100002), \"nickname\" : \"下江\" }\n\n# special limit\n$ mp \"select _id,nickname from user where _id in (100002,100003) order by _id desc limit 1,1\"\n# =\u003e\n{ \"_id\" : NumberLong(100002), \"nickname\" : \"下江\" }\n\n# collaboration with other unix tool\n$ mp \"select _id,nickname from user where _id in (100002,100003) order by _id desc limit 10\" | b2j | jq .nickname\n# =\u003e\n\"就是辣么帅2323\"\n\"下江\"\n\n```\n\n![case](doc/showcase.png)\n\n---\n\n# Feature\n- support base binary op.\n=,!=,\u003e ...\nin, not in.\n\n- and, or, ().\n\n- build the binary executable file\n\n# Note\nit build for myself.\n\n# Changelog\n- basic available\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguxingke%2Fsql2mongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguxingke%2Fsql2mongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguxingke%2Fsql2mongo/lists"}