{"id":19356439,"url":"https://github.com/haizlin/h-mysql","last_synced_at":"2025-10-16T18:44:19.258Z","repository":{"id":108699345,"uuid":"227567910","full_name":"haizlin/h-mysql","owner":"haizlin","description":"一直以来很喜欢Thinkphp的数据操作风格，所以在nodejs上也封装了一个MYSQL数据库的常用操作，支持链式调用，实现语义化的数据库操作。","archived":false,"fork":false,"pushed_at":"2024-12-26T08:06:08.000Z","size":411,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T00:04:03.264Z","etag":null,"topics":["javascript","mysql","node-mysql","nodejs","orm"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/haizlin.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-12-12T09:25:18.000Z","updated_at":"2024-12-26T08:06:11.000Z","dependencies_parsed_at":"2023-03-13T14:24:10.019Z","dependency_job_id":null,"html_url":"https://github.com/haizlin/h-mysql","commit_stats":{"total_commits":50,"total_committers":2,"mean_commits":25.0,"dds":0.06000000000000005,"last_synced_commit":"eeea5c489113a133d0c5a9756b03719337ed34a8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haizlin%2Fh-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haizlin%2Fh-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haizlin%2Fh-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haizlin%2Fh-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haizlin","download_url":"https://codeload.github.com/haizlin/h-mysql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250416761,"owners_count":21427050,"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","mysql","node-mysql","nodejs","orm"],"created_at":"2024-11-10T07:04:29.368Z","updated_at":"2025-09-25T21:20:01.898Z","avatar_url":"https://github.com/haizlin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# h-mysql\n\n* **网站**：[访问项目github地址](https://github.com/haizlin/h-mysql)\n* **介绍**：一直以来很喜欢Thinkphp的数据操作风格，所以在nodejs上也封装了一个MYSQL数据库的常用操作，支持链式调用，实现语义化的数据库操作。\n\n## 安装及引用\n\n```javascript\n\n// npm安装\nnpm i h-mysql --save\n\n// yarn安装\nyarn add h-mysql\n\nconst hMysql = require('h-mysql');\n```\n\n## 初始化配置\n```javascriipt\nconst hMysql = new mysql({\n  host: '127.0.0.1',\n  user: 'root',\n  password: '',\n  database: 'test-db',\n  port: 3306,\n\n  acquireTimeout: 1000,\n  waitForConnections: true,     //是否等待链接  \n  connectionLimit: 10,          // 连接池数\n  queueLimit: 0,                // 排队限制 \n\n  defaultSqlPre: '',\n  isPool: true,\n  isDebug: true\n});\n\nconst {error, result} = await hMysql.table('user')\n  .where({ id: 100 })\n  .select()\n  .execSql();\n\nconsole.log(result);\n```\n\n## 调用方式\n\u003e 规则：调用方法跟顺序无关\n```javascript\nlet hMysql = new hMysql(config)\n\nhMysql.table()\n      .where()\n      .limit()\n      .select()\n      .execSql()\n```\n\n## [CURD操作](./docs/api.md)\n* 添加：[insert] [table] [data]\n* 查询：[select] [field] from [table] [alias] [where] [join]\n* 更新：[update] [table] set [data] [where]\n* 删除：[delete] from [table] [where]\n\n## [API 文档](./docs/api.md)\n* CURD操作\n  * [.find()]() ⇒ Promise\n  * [.select()]() ⇒ Promise\n  * [.update()]() ⇒ Promise\n  * [.updateMany()]() ⇒ Promise\n  * [.insert()]() ⇒ Promise\n  * [.delete()]() ⇒ Promise\n  * [.query(sql: string)]() ⇒ Promise\n\n* 链式方法\n  * [.table(tableName: string)]() ⇒ Mysql\n  * [.alias(tableAlias: string)]()⇒ Mysql\n  * [.field(opt: string | any[])]() ⇒ Mysql\n  * [.where(opt: string | any[])]() ⇒ Mysql\n  * [.limit(limit)]() ⇒ Mysql\n  * [.page(pageSize, pageNum)]() ⇒ Mysql\n  * [.data(data:object)]() ⇒ Mysql\n  * [.order(order)]() ⇒ Mysql\n  * [.join()]() ⇒ Mysql\n  * [.union()]() ⇒ Mysql\n  * [.count()]() ⇒ Promise\n  * [.group(field)]() ⇒ Mysql\n  * [.having(field)]() ⇒ Mysql\n  * [.count(field)]() ⇒ Mysql\n  * [.max(field)]() ⇒ Mysql\n  * [.min(field)]() ⇒ Mysql\n  * [.avg(field)]() ⇒ Mysql\n  * [.sum(field)]() ⇒ Mysql\n  * [.lock(field, step)]() ⇒ Promise\n  * [.distinct(field, step)]() ⇒ Promise\n  * [.comment(str:string)]() ⇒ Promise\n  * [.execSql()]() ⇒ string\n\n## 迭代计划\n- [ ] 完善API文档、架构文档\n- [ ] 完善案例\n- [ ] 批量插入、批量更新、批量删除\n- [ ] 支持更复杂的链式操作\n- [ ] 添加测试用例\n- [ ] 重写异常处理方式\n- [ ] 添加性能测试、性能优化并添加每条语句执行的时间\n- [ ] 添加安全测试，防注入\n- [ ] 增加对数据库的操作（现在的功能都是针对表）\n- [ ] 考虑是不是要支持ORM\n\n\n## 版本更新\n* v1.0.0\n  * 实现常用方法的链式调用，未经过测试，慎用到生产环境，待更新到完善\n\n## 项目骨干\n- [qq674785876](https://github.com/qq674785876)\n- [undefinedYu](https://github.com/undefinedYu)\n- [qingleizhang123](https://github.com/qingleizhang123)\n- [yxkhaha](https://github.com/yxkhaha)\n- [zhaoqian0901](https://github.com/zhaoqian0901)\n\n## 贡献\n欢迎大家到 [Issues](https://github.com/haizlin/h-mysql/issues) 交流或通过提交**PR**的形式对本项目进行贡献\n\n## License\n[![MIT](http://api.haizlin.cn/api?mod=interview\u0026ctr=issues\u0026act=generateSVG\u0026type=h-mysql)](https://github.com/haizlin/h-mysql/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaizlin%2Fh-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaizlin%2Fh-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaizlin%2Fh-mysql/lists"}