{"id":20757406,"url":"https://github.com/dangdungcntt/sql-to-mongodb-query","last_synced_at":"2026-02-09T05:37:42.176Z","repository":{"id":57024409,"uuid":"320177716","full_name":"dangdungcntt/sql-to-mongodb-query","owner":"dangdungcntt","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-18T02:21:22.000Z","size":148,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-27T10:06:28.545Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/dangdungcntt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-10T06:13:43.000Z","updated_at":"2024-11-29T01:14:26.000Z","dependencies_parsed_at":"2024-05-17T16:03:53.974Z","dependency_job_id":"543f275e-05f0-41e5-9388-925360faa601","html_url":"https://github.com/dangdungcntt/sql-to-mongodb-query","commit_stats":{"total_commits":60,"total_committers":1,"mean_commits":60.0,"dds":0.0,"last_synced_commit":"bedc7de8b475ff21872309321ba2c5796b386d29"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":"spatie/package-skeleton-laravel","purl":"pkg:github/dangdungcntt/sql-to-mongodb-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dangdungcntt%2Fsql-to-mongodb-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dangdungcntt%2Fsql-to-mongodb-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dangdungcntt%2Fsql-to-mongodb-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dangdungcntt%2Fsql-to-mongodb-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dangdungcntt","download_url":"https://codeload.github.com/dangdungcntt/sql-to-mongodb-query/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dangdungcntt%2Fsql-to-mongodb-query/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262235779,"owners_count":23279566,"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":[],"created_at":"2024-11-17T09:42:04.909Z","updated_at":"2026-02-09T05:37:37.077Z","avatar_url":"https://github.com/dangdungcntt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sql-to-mongodb-query\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/nddcoder/sql-to-mongodb-query.svg?style=flat-square)](https://packagist.org/packages/nddcoder/sql-to-mongodb-query)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/dangdungcntt/sql-to-mongodb-query/run-tests.yml?branch=master)](https://github.com/dangdungcntt/sql-to-mongodb-query/actions?query=workflow%3Atests+branch%3Amaster)\n[![Total Downloads](https://img.shields.io/packagist/dt/nddcoder/sql-to-mongodb-query.svg?style=flat-square)](https://packagist.org/packages/nddcoder/sql-to-mongodb-query)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require nddcoder/sql-to-mongodb-query\n```\n\n## Online Demo\n\n[SQL To MongoDB Query](https://nddapp.com/sql-to-mongodb-query-converter.html)\n\n## GUI phpMongoAdmin\n\n[phpMongoAdmin](https://github.com/dangdungcntt/phpmongoadmin)\n\n## Usage\n\nParse Find query\n\n```php\n$parser = new Nddcoder\\SqlToMongodbQuery\\SqlToMongodbQuery();\n$query = $parser-\u003eparse(\"\n    SELECT id, username, email, created_at \n    FROM users\n    USE INDEX active_1_created_at_1\n    WHERE active = true and created_at \u003e= date('2021-01-01') \n    ORDER BY created_at desc \n    LIMIT 10, 20\n\");\n\n/*\nNddcoder\\SqlToMongodbQuery\\Model\\FindQuery {#473\n  +filter: array:2 [\n    \"active\" =\u003e true\n    \"created_at\" =\u003e array:1 [\n      \"$gte\" =\u003e MongoDB\\BSON\\UTCDateTime {#926\n        +\"milliseconds\": \"1609459200000\"\n      }\n    ]\n  ]\n  +projection: array:4 [\n    \"id\" =\u003e 1\n    \"username\" =\u003e 1\n    \"email\" =\u003e 1\n    \"created_at\" =\u003e 1\n  ]\n  +sort: array:1 [\n    \"created_at\" =\u003e -1\n  ]\n  +limit: 20\n  +skip: 10\n  +collection: \"users\"\n  +hint: \"active_1_created_at_1\"\n}\n\n*/\n```\n\nParse Aggregate query\n\n```php\n$parser = new Nddcoder\\SqlToMongodbQuery\\SqlToMongodbQuery();\n$query = $parser-\u003eparse(\"\n    SELECT date, count(*)\n    FROM clicks\n    USE INDEX status_1_created_at_1\n    WHERE status = 1 and created_at \u003e= date('2021-07-01') \n    GROUP BY date\n    HAVING count(*) \u003e 100\n\");\n\n/*\nNddcoder\\SqlToMongodbQuery\\Model\\Aggregate {#493\n  +pipelines: array:4 [\n    0 =\u003e array:1 [\n      \"$match\" =\u003e array:2 [\n        \"status\" =\u003e 1\n        \"created_at\" =\u003e array:1 [\n          \"$gte\" =\u003e MongoDB\\BSON\\UTCDateTime {#926\n            +\"milliseconds\": \"1625097600000\"\n          }\n        ]\n      ]\n    ]\n    1 =\u003e array:1 [\n      \"$group\" =\u003e array:2 [\n        \"_id\" =\u003e array:1 [\n          \"date\" =\u003e \"$date\"\n        ]\n        \"count(*)\" =\u003e array:1 [\n          \"$sum\" =\u003e 1\n        ]\n      ]\n    ]\n    2 =\u003e array:1 [\n      \"$project\" =\u003e array:3 [\n        \"date\" =\u003e \"$_id.date\"\n        \"count(*)\" =\u003e \"$count(*)\"\n        \"_id\" =\u003e 0\n      ]\n    ]\n    3 =\u003e array:1 [\n      \"$match\" =\u003e array:1 [\n        \"count(*)\" =\u003e array:1 [\n          \"$gt\" =\u003e 100\n        ]\n      ]\n    ]\n  ]\n  +collection: \"clicks\"\n  +hint: \"status_1_created_at_1\"\n}\n*/\n```\n\n## Testing\n\n``` bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Dung Nguyen Dang](https://github.com/dangdungcntt)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdangdungcntt%2Fsql-to-mongodb-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdangdungcntt%2Fsql-to-mongodb-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdangdungcntt%2Fsql-to-mongodb-query/lists"}