{"id":44003990,"url":"https://github.com/yisbug/restify-curd","last_synced_at":"2026-02-07T13:07:27.128Z","repository":{"id":29085207,"uuid":"32613499","full_name":"yisbug/restify-curd","owner":"yisbug","description":"通用的collection操作，直接生成对应的路由，提供基础的restful接口，包含GET,POST,PATCH,DEL等。支持操作子文档。","archived":false,"fork":false,"pushed_at":"2017-01-14T02:56:09.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-05T23:18:47.783Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","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/yisbug.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":"2015-03-21T00:14:09.000Z","updated_at":"2017-01-14T02:55:56.000Z","dependencies_parsed_at":"2022-09-11T15:31:37.132Z","dependency_job_id":null,"html_url":"https://github.com/yisbug/restify-curd","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/yisbug/restify-curd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisbug%2Frestify-curd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisbug%2Frestify-curd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisbug%2Frestify-curd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisbug%2Frestify-curd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yisbug","download_url":"https://codeload.github.com/yisbug/restify-curd/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yisbug%2Frestify-curd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29194626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T12:38:28.597Z","status":"ssl_error","status_checked_at":"2026-02-07T12:38:23.888Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-02-07T13:07:26.473Z","updated_at":"2026-02-07T13:07:27.114Z","avatar_url":"https://github.com/yisbug.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# restify-curd\n\n通用的collection操作，包含`GET`,`POST`,`PATCH`,`DEL`等。\n\n### TODO\n* 内嵌文档支持分页\n* 支持无限极内嵌文档\n* 支持更多的查询条件\n\n### 更新\n\n#### 1.0.6\n\n* 使用了最新版本mongoose@4.4.3，固定package.json的依赖版本号\n* 修复了mongoose@4.x修改的findOneAndUpdate第三个参数导致的更新数据失败bug\n* 修正README.md\n* 添加了集成测试\n\n#### 1.0.5\n* childs参数支持最多3级\n* 当`put`,`patch`内嵌文档时，因为mongodb问题，更新操作非原子操作。\n\n#### 1.0.4\n\n* 增加一个options参数childs，可以指定查询内嵌文档\n* 增加一个批量删除接口\n\n#### 1.0.3\n\n* 参数由原先的(server,db,modelName,schemaConfig,options)修改为(server,Model,options)\n* createAt和random字段由默认配置修改为schema动态添加\n* 如果传入的Model.schema中未设置createAt和random字段时，REST请求将无法获取这两个字段。\n* `options`参数增加一个字段`path`，标识路由路径，默认为`Model.modelName`，不需要加`/`\n\n\n\n\n\n### Installation\n\n    npm install restify-curd\n\n### 使用\n\n``` coffee\nrestify = require 'restify'\nmongoose = require 'mongoose'\ncurd = require 'restify-curd'\n\nserver = restify.createServer()\ndb = mongoose.createConnection 'mongodb://localhost/restify-curd-test'\ndb.once 'open',-\u003e\n    Model = db.model 'test',schema\n    curd (server,Model,options)\n    server.listen port,-\u003e\n        console.log 'server start.'\n```\n\n### 参数\n\n* `server` object\n* `Model` mongoose Model\n* `options` object\n\noptions参数\n* `list` boolean 是否开放获取列表接口，默认开放\n* `post` boolean 是否开放新建接口，默认开放\n* `get` boolean 是否开放获取详情接口，默认开放\n* `put` boolean 是否开放修改接口，默认开放\n* `patch` boolean 是否开放修改接口，默认开放\n* `del` boolean 是否开放删除接口，默认开放\n* `delAll` boolean 是否开放批量删除接口，默认开放\n* `path` String 路由资源地址，默认为Model.modelName\n* `childs` Array/Object 指定一个内嵌文档字段和开放的接口\n\nchilds参数：\n* `list` `post` `get` `put` `patch` `del` `delAll`\n* `path` 内嵌文档的字段名称和路径\n\n### 其他默认设置\n\n* 默认为schemaConfig添加createAt和random两个数字类型数字，一个标识创建资源的时间，一个为小于1的随机数字，用于获取随机数据。\n\n### `GET /collection` 获取列表\n参数：\n* limit number\n* page number\n* sortby string 默认按createAt大小逆序排列\n* desc asc/desc\n* fields string 逗号分隔的字符串\n\n返回：\n\n* count number\n* page number\n* limit number\n* sortby string\n* desc asc/desc\n* list array\n\n### `POST /collection` 新建\n返回新建的记录\n\n### `GET /collection/:id` 查询指定id的记录\n参数：\n* fields string 逗号分隔的字符串\n\n### `PUT /collection/:id` 更新指定id的记录\n返回该记录信息\n\n### `PATCH /collection/:id` 修改指定id的记录\n返回该记录信息\n\n### `DELETE /collection/:id` 删除指定id的记录\n\n### `DELETE /collection` 删除符合条件的记录\n参数：\n* 所有条件作为queryString\n\n\n## 内嵌文档\n\n当options参数中指定了childs参数时，会自动为内嵌文档增加对应的路由\n\n### `POST /collection/:id/child` 新增一个内嵌文档\n返回新建的记录。\n\n### `GET /collection/:id/child` 查询所有内嵌文档\n注意该地址和父文档不同，不支持分页排序等，只会返回所有记录。\n\n### 其他路由同父文档。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyisbug%2Frestify-curd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyisbug%2Frestify-curd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyisbug%2Frestify-curd/lists"}