{"id":16060521,"url":"https://github.com/orgoldfus/sql2mongo","last_synced_at":"2025-06-24T07:38:06.356Z","repository":{"id":35206261,"uuid":"214407982","full_name":"orgoldfus/sql2mongo","owner":"orgoldfus","description":"Use SQL to query MongoDB","archived":false,"fork":false,"pushed_at":"2023-03-04T04:55:21.000Z","size":355,"stargazers_count":16,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-24T18:43:12.924Z","etag":null,"topics":["hacktoberfest","mongo","mongodb","parser","sql"],"latest_commit_sha":null,"homepage":"","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/orgoldfus.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}},"created_at":"2019-10-11T10:26:11.000Z","updated_at":"2024-01-04T15:07:03.000Z","dependencies_parsed_at":"2024-10-27T15:31:42.029Z","dependency_job_id":"f73a0f08-1a4c-4866-996b-6282bcd75c56","html_url":"https://github.com/orgoldfus/sql2mongo","commit_stats":{"total_commits":35,"total_committers":4,"mean_commits":8.75,"dds":0.4,"last_synced_commit":"3a75b3138fa447e2cbc16b6f7d16b0281bd8808a"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/orgoldfus/sql2mongo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orgoldfus%2Fsql2mongo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orgoldfus%2Fsql2mongo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orgoldfus%2Fsql2mongo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orgoldfus%2Fsql2mongo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orgoldfus","download_url":"https://codeload.github.com/orgoldfus/sql2mongo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orgoldfus%2Fsql2mongo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261630725,"owners_count":23187222,"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","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":["hacktoberfest","mongo","mongodb","parser","sql"],"created_at":"2024-10-09T04:05:07.171Z","updated_at":"2025-06-24T07:38:06.328Z","avatar_url":"https://github.com/orgoldfus.png","language":"JavaScript","readme":"# sql2mongo [![Build Status][travis-image]][travis-url] ![npm](https://img.shields.io/npm/v/sql2mongo)\n\nUse SQL syntax to query MongoDB\n\n## Installation\n```\nnpm install sql2mongo\n```\n\n## Usage\n### getMongoQuery\nParses an SQL WHERE clause to a mongo query object.\n\nExample:\n```js\nconst { getMongoQuery } = require(\"sql2mongo\");\n\nconst mongoQuery = getMongoQuery(`\n  show = \"Friends\" OR\n  (city = \"New York\" AND\n  year BETWEEN 2005 AND 2014 AND\n  name IN (\"Ted\", \"Marshall\", \"Barney\"))\n`)\n```\n\nResult:\n```js\n{\n  $or: [\n    { show: \"Friends\" },\n    {\n      city: \"New York\",\n      year: { $gt: 2005, $lt: 2014 },\n      name: { $in: [\"Ted\", \"Marshall\", \"Barney\"] },\n    }\n  ]\n}\n```\n\n#### Nested objects\nIf you need to query a nested object, use the `NESTED` function inside your query.\nThe `NESTED` function receives a string with a WHERE clause for the nested object.\n\nExample:\nIf you would like to query the following nested document:\n```js\n{\n  item: 'journal',\n  qty: 25,\n  size: { h: 14, w: 21, uom: 'cm' },\n  status: 'A'\n}\n```\n\nYou can use the `NESTED` function like this:\n```js\nconst { getMongoQuery } = require(\"sql2mongo\");\n\nconst mongoQuery = getMongoQuery(`\n  size = NESTED(\"h = 14 AND w \u003e 20\")\n`)\n```\n\nResult:\n```js\n{\n  size: {\n    h: 14,\n    w: { $gt: 20 }\n  }\n}\n```\n\nOtherwise, you can use the dot annotation:\n```js\nconst { getMongoQuery } = require(\"sql2mongo\");\n\nconst mongoQuery = getMongoQuery(`\n  size.h = 14 AND \n  size.w \u003e 20\n`)\n```\n\nResult:\n```js\n{\n  \"size.h\": 14,\n  \"size.w\": { $gt: 20 }\n}\n```\n\n## TODO\n- Add support for all DML commands (insert, update, etc.)\n\n## Build\n- Run `npm run build` to build the package.\n\n## LICENSE\nMIT\n\n[travis-image]: https://travis-ci.com/orgoldfus/sql2mongo.svg?branch=master\n[travis-url]: https://travis-ci.com/orgoldfus/sql2mongo\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forgoldfus%2Fsql2mongo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forgoldfus%2Fsql2mongo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forgoldfus%2Fsql2mongo/lists"}