{"id":26473025,"url":"https://github.com/unicreators/sql-criteria-parser","last_synced_at":"2025-10-07T01:02:05.457Z","repository":{"id":57368184,"uuid":"88482167","full_name":"unicreators/sql-criteria-parser","owner":"unicreators","description":"javascript sql criteria expression parser.","archived":false,"fork":false,"pushed_at":"2017-04-22T03:17:26.000Z","size":4,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-08-24T07:15:25.299Z","etag":null,"topics":["javascript","sql-parser"],"latest_commit_sha":null,"homepage":null,"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/unicreators.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}},"created_at":"2017-04-17T07:13:45.000Z","updated_at":"2022-03-04T09:23:18.000Z","dependencies_parsed_at":"2022-09-05T20:51:13.392Z","dependency_job_id":null,"html_url":"https://github.com/unicreators/sql-criteria-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unicreators%2Fsql-criteria-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unicreators%2Fsql-criteria-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unicreators%2Fsql-criteria-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unicreators%2Fsql-criteria-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unicreators","download_url":"https://codeload.github.com/unicreators/sql-criteria-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244513916,"owners_count":20464601,"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":["javascript","sql-parser"],"created_at":"2025-03-19T21:50:40.248Z","updated_at":"2025-10-07T01:02:00.403Z","avatar_url":"https://github.com/unicreators.png","language":"JavaScript","readme":"## SqlCriteriaParser\n\n一个可以将 javascript 对象表达式转换为 T-SQL 条件语句的转换器。\n\n\n```js\nlet e = {\n    '$or': {\n        '$or': {\n            'name': {\n                '$or': { '$=': 'yichen', '$endsWith': 'a' }\n            },\n            'age': { '$\u003e': 10, '$\u003c': 22 }\n        },\n        'gender': 1,\n        'level': [1, 2, 3],\n        'size': { '$in': [18, 19] }\n    }\n};\n\nlet { segment, values } = sqlCriteriaParser.parse(e);\n\n\nconsole.log(segment);\n// (((name = ?) OR (name LIKE ?)) OR ((age \u003e ?) AND (age \u003c ?))) OR (gender = ?) OR (level IN (?)) OR (size IN (?))\n\nconsole.log(values);\n// ['yichen', '%a', 10, 22, 1, [1, 2, 3], [18, 19]]\n\n```\n\n\n## Install\n\n```sh\n$ npm install sql-criteria-parser\n```\n\n\n## Usage\n\n```js\nconst SqlCriteriaParser = require('sql-criteria-parser');\n\nlet parser = new SqlCriteriaParser('?');\n\nlet e = { '$or': { 'name': 'yichen', 'age': 22 } };\nlet { segment, values } = parser.parse(e);\n\nconsole.log(segment);\n// '(name = ?) OR (age = ?)'\n\nconsole.log(values);\n// ['yichen', 22]\n\n```\n\n## Operator\n\n- `$=` to `=`\n- `$\u003e` to `\u003e`\n- `$\u003c` to `\u003c`\n- `$\u003e=` to `\u003e=`\n- `$\u003c=` to `\u003c=`\n- `$\u003c\u003e` to `\u003c\u003e`\n- `$startsWith` to `LIKE`\n- `$endsWith` to `LIKE`\n- `$contains` to `LIKE`\n- `$in` to `IN`\n  \n  \n- `$and` to `AND`\n- `$or` to `OR`\n\n\n\n\n### License\n\n[MIT](LICENSE)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funicreators%2Fsql-criteria-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funicreators%2Fsql-criteria-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funicreators%2Fsql-criteria-parser/lists"}