{"id":26879991,"url":"https://github.com/ppiyush13/json-sql-utility","last_synced_at":"2025-05-07T20:12:08.595Z","repository":{"id":36069856,"uuid":"221267917","full_name":"ppiyush13/json-sql-utility","owner":"ppiyush13","description":"Simple utility for converting JSON to SQL","archived":false,"fork":false,"pushed_at":"2023-01-05T00:47:23.000Z","size":1456,"stargazers_count":4,"open_issues_count":14,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T20:12:01.770Z","etag":null,"topics":["json-2-sql","json-sql","json-sql-utility","json-to-sql","json2sql","jsonsql"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/ppiyush13.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}},"created_at":"2019-11-12T16:55:46.000Z","updated_at":"2025-03-12T11:44:19.000Z","dependencies_parsed_at":"2023-01-16T12:46:43.029Z","dependency_job_id":null,"html_url":"https://github.com/ppiyush13/json-sql-utility","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppiyush13%2Fjson-sql-utility","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppiyush13%2Fjson-sql-utility/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppiyush13%2Fjson-sql-utility/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ppiyush13%2Fjson-sql-utility/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ppiyush13","download_url":"https://codeload.github.com/ppiyush13/json-sql-utility/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252949285,"owners_count":21830153,"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":["json-2-sql","json-sql","json-sql-utility","json-to-sql","json2sql","jsonsql"],"created_at":"2025-03-31T13:34:29.383Z","updated_at":"2025-05-07T20:12:08.571Z","avatar_url":"https://github.com/ppiyush13.png","language":"JavaScript","readme":"# json-sql-utility\r\n\r\n[![module verion and npm link][npm]][npm-url]\r\n[![bundlephobia minified size][size-min]][bundlephobia-url]\r\n[![bundlephobia minizipped size][size-minzip]][bundlephobia-url]\r\n\r\nThis module is useful for buidling SQL queries from JSON objects.\r\nCurrently only SELECT query is supported.\r\n\r\n## Install\r\n```javascript\r\nyarn add json-sql-utility\r\nor\r\nnpm i json-sql-utility\r\n```\r\n\r\n## Usage\r\nSimple example\r\n\r\n```javascript\r\nimport { select } from \"json-sql-utility\"\r\n\r\nconst query = select({\r\n    fields: ['A', 'B'],\r\n    aggregation: [ \r\n        {\r\n            fn: 'count',\r\n            args: 'D',\r\n            alias: 'CNT'\r\n        }\r\n    ],\r\n    from: 'STUDENTS',\r\n    where: [\r\n        {\r\n            operator: 'equal',\r\n            field: 'NAME',\r\n            value: 'Piyush'\r\n        },\r\n        {\r\n            operator: '=',\r\n            field: 'ROLL',\r\n            value: [13],\r\n        },\r\n        {\r\n            operator: 'OR',\r\n            conditions: [\r\n                {\r\n                    operator: 'equal',\r\n                    field: 'A',\r\n                    value: 5,\r\n                },\r\n                {\r\n                    operator: 'equal',\r\n                    field: 'A',\r\n                    value: 10,\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            operator: 'dateBetween',\r\n            field: 'BIRTH',\r\n            value: {\r\n                start: new Date(1975, 0, 1),\r\n                end: new Date(1999, 11, 31),\r\n            }\r\n        },\r\n    ],\r\n    groupBy: ['A', 'B', 'C'],\r\n    orderBy: ['A'],\r\n    misc: [\r\n        \"EXTERNAL NAME 'TestFuncs$MyMath.pow'\"\r\n    ],\r\n});\r\n\r\nconsole.log(query);\r\n\r\n/*\r\nWill output:\r\n\r\nSELECT A, B, count(D) AS CNT FROM STUDENTS\r\nWHERE NAME = 'Piyush' AND ROLL = 13 AND (A = 5 OR A = 10) AND \r\nBIRTH BETWEEN '1975-01-01' AND '1999-12-31'\r\nGROUP BY A, B, C\r\nORDER BY A\r\nEXTERNAL NAME 'TestFuncs$MyMath.pow'\r\n\r\n*/\r\n```\r\n\r\n\r\n[npm]: https://img.shields.io/npm/v/json-sql-utility.svg\r\n[npm-url]: https://www.npmjs.com/package/json-sql-utility\r\n[size-min]: https://img.shields.io/bundlephobia/min/json-sql-utility\r\n[size-minzip]: https://img.shields.io/bundlephobia/minzip/json-sql-utility\r\n[bundlephobia-url]: https://bundlephobia.com/result?p=json-sql-utility\r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppiyush13%2Fjson-sql-utility","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fppiyush13%2Fjson-sql-utility","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fppiyush13%2Fjson-sql-utility/lists"}