{"id":22325221,"url":"https://github.com/koahubjs/koahub-mysql","last_synced_at":"2025-07-29T16:32:44.830Z","repository":{"id":49380833,"uuid":"85585064","full_name":"koahubjs/koahub-mysql","owner":"koahubjs","description":"KoaHub Mysql -- KoaHub.js mysql库","archived":false,"fork":false,"pushed_at":"2022-07-25T09:04:00.000Z","size":48,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-12-16T06:34:04.275Z","etag":null,"topics":["bookshelf","koa","koa2","koahub","koahubjs","mysql","node","node-mysql","node-orm","nodejs","orm"],"latest_commit_sha":null,"homepage":"http://js.koahub.com","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/koahubjs.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-03-20T14:14:09.000Z","updated_at":"2023-12-16T06:34:04.276Z","dependencies_parsed_at":"2022-08-25T06:10:43.664Z","dependency_job_id":null,"html_url":"https://github.com/koahubjs/koahub-mysql","commit_stats":null,"previous_names":[],"tags_count":4,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koahubjs%2Fkoahub-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koahubjs%2Fkoahub-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koahubjs%2Fkoahub-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koahubjs%2Fkoahub-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koahubjs","download_url":"https://codeload.github.com/koahubjs/koahub-mysql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228030042,"owners_count":17858432,"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":["bookshelf","koa","koa2","koahub","koahubjs","mysql","node","node-mysql","node-orm","nodejs","orm"],"created_at":"2024-12-04T02:10:51.066Z","updated_at":"2024-12-04T02:10:51.673Z","avatar_url":"https://github.com/koahubjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 介绍\n\nKoaHub Mysql -- KoaHub.js mysql库。\n\n## 特性\n1. 支持created_at, updated_at时间戳\n2. 支持 `find`, `findPage`, `findAll`, `add`, `addAll` `save`, `saveAll`, `delete`, `deleteAll`\n3. ...\n\n## 安装\n```js\nnpm install koahubjs/koahub-mysql --save\n```\n\n## 使用\n\n```javascript\n//创建app/middleware/mysql.middleware.js\nmodule.exports = require('koahub-mysql');\n//配置app/config/middleware.config.js\nmodule.exports = {\n   mysql: {\n     \"host\": \"127.0.0.1\",\n     \"user\": \"root\",\n     \"password\": \"\",\n     \"database\": \"koahub\",\n  }\n}\n//配置app/config/default.config.js\nmodule.exports = {\n   loader: {\n        \"models\": {\n            root: 'model',\n            suffix: '.model.js'\n        }\n    }\n}\n```\n\n### 入门\n```js\n// app/home/index.controller.js\nmodule.exports = class extends koahub.controller {\n\n    async _initialize() {\n        // 控制器初始化\n    }\n\n    async index() {\n    \t \n    \tconst user = await this.model('user').findAll();\n        this.view(user);\n    }\n}\n\n// app/model/user.model.js\nmodule.exports = koahub.model.extend({\n    tableName: 'user',\n    hasTimestamps: true\n});\n```\n### API\n```\n// 查询\nthis.model('user').find();\n// 查询分页\nthis.model('user').findPage();\n// 查询所有\nthis.model('user').findAll();\n// 新增或者修改\nthis.model('user').add();\n// 新增或者修改所有\nthis.model('user').addAll();\n// 新增或者修改\nthis.model('user').save();\n// 新增或者修改所有\nthis.model('user').saveAll();\n// 删除\nthis.model('user').delete();\n// 删除所有\nthis.model('user').deleteAll();\n\n// 更多方法请参考bookshelf\nthis.model('user').query();\nthis.model('user').count();\nthis.model('user').where();\n...\n\n```\n\n## KoaHub.js\n[KoaHub.js框架](https://github.com/koahubjs/koahub)\n\n## 官网\n[KoaHub.js官网](http://js.koahub.com)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoahubjs%2Fkoahub-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoahubjs%2Fkoahub-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoahubjs%2Fkoahub-mysql/lists"}